Bill Jonas on Mon, 27 Aug 2001 05:20:10 +0200


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

[PLUG] Vim paragraph reformatting


Okay, so I either learned or suggested a while ago, in response to a
question about how to reformat a paragraph with Vim, to use '{gq}' key
combination -- '{' to move to the start of the paragraph, and 'gq}' to
reformat to the end of the paragraph.  (This works as long as you have
your textwidth set.)  I also recall someone saying that they didn't like
hitting the shift key twice to do this.  (A cursory examination of my
PLUG mailbox didn't reveal clues, and it's not all that important
anyway.  It might've even been on another mailing list, but that's
fine.)

Anyway, I was looking around at vim.org this evening and noticed, at
http://www.vim.org/why.html, that Vim extends the idea of moving from
one {word,sentence,paragraph,etc} to the next to having the notion of
"extended text objects" -- that you have a "current word" or "current
paragraph".  So, for example, you can reformat the current paragraph
with 'gqip' -- that's reformat "inner paragraph".  (Doesn't include
surrounding whitespace.)  So now you don't have to hit the shift key at
all.  :)

See ':help text-objects' for more info.

-- 
Bill Jonas    *    bill@billjonas.com    *    http://www.billjonas.com/
"As we enjoy great advantages from the inventions of others,  we should
be glad of an opportunity to serve others by any invention of ours; and
this we should do freely and generously."          -- Benjamin Franklin


______________________________________________________________________
Philadelphia Linux Users Group       -      http://www.phillylinux.org
Announcements-http://lists.phillylinux.org/mail/listinfo/plug-announce
General Discussion  -  http://lists.phillylinux.org/mail/listinfo/plug