Sunday, July 29, 2007

text formatting with vim and vi

Vim helped me out twice over the last few days.

A virus spam complaint about our postfix server - could use the "find" command to easily locate the surrounding lines in /var/log/mail/info to show that it was just bouncing a virus mail.

Find (forward) in vi = /characters_to_find
Find backwards = ?characters_to_find
Find next = n
Find next in the opposite direction = N

The next tip was from a thread in the comments section of an article on freshmeat on how to make emails palatable to the Linux community.

we vim users have an extra-nifty trick available.
gq} will reformat the current paragraph, while magically preserving > > -style quoting!
gq/^--/-1 will do it from the cursor until your signature, which is even better.
The second part is not working for me - it complains about no match for ^--

But gq} works when there are paragraph breaks - two newlines.

No comments:

Post a Comment