sponsor Vim development Vim logo Vim Book Ad

basic Tip #273: Fast fixing of email quotations (too long lines)

 tip karma   Rating 82/31, Viewed by 2321 

created:   July 5, 2002 4:24      complexity:   basic
author:   anonymous      as of Vim:   5.7


When using VIM as your editor of choice, even for email processing - as I do - it is often unpleasing how some MUA's quote the email body produced by mailers such as Outlook. The lines often span across multiple visual lines and its difficult to reply on certain parts of it.

With VIM, you can quickly fix those quotations to maintain a proper 75 char break. For example, when using Mutt, put this line in your .muttrc, or use a custom .vimrc_mail for it:

set editor="vim -c 'set fo=tcrq' -c 'set tw=76'"

For other MUA's this has to be fitted. However, now, when your quoted email is displayed, you can use this VIM sequence to fix it:

1. move cursor to first line of broken paragraph
2. press 'V' and move to the last line of the paragraph you want to fix
3. press 'g' and then 'q'. The marked text will wrap around to your specified textwidth (76 in our case) and the quotations will be preserved across the lines

 rate this tip  Life Changing Helpful Unfulfilling 

<<automaticaly formating pasted text (p=`]) | Some useful mappings for TeX >>

Additional Notes

Anonymous, July 20, 2002 11:39
You can also simply use the { and } paragraph motions in conjunction with 'gq'. F.ex move to the top of a paragraph using {, then hit gq} to reformat it.
[email protected], August 16, 2002 3:36
Like just about everything else, gq will take any motion command. I find myself stepping through mails and random files with :set tw=72 or whatnot and gqj and J and occasionally inserting stray >'s.
Olaf Schulz <[email protected]>, June 18, 2003 14:09
There are some additional conditions to be met, but which?

The tip works with an empty/missing ~/.vimrc but not with my .vimrc although the parameters tw and fo are set as mentioned. Any clue, where I could look for don't want to post my 227 lines ~/.vimrc here, but
http://www.village.in-berlin.de/setup/vimrc
Olaf Schulz, June 18, 2003 15:00
the comments setting must contain the quoting character (usually '>')
so with
set comments=s1:/*,mb:*,ex:*/,://,b:#,:%,:XCOMM,n:>,fb:-
everything works as described.
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to [email protected] after searching the archive. Help Bram help Uganda.
Sponsored by Web Concept Group Inc. SourceForge Logo