Vim Tips Wiki
(Remove html character entities)
(change "anon" author to blank; trim "created" date; minor manual clean)
Line 4: Line 4:
 
|previous=272
 
|previous=272
 
|next=275
 
|next=275
|created=July 5, 2002
+
|created=2002
 
|complexity=basic
 
|complexity=basic
|author=Anon
+
|author=
 
|version=5.7
 
|version=5.7
 
|rating=87/33
 
|rating=87/33
Line 15: Line 15:
   
 
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:
 
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:
  +
<pre>
set editor="vim -c 'set fo=tcrq' -c 'set tw=76'"
+
set editor="vim -c 'set fo=tcrq' -c 'set tw=76'"
  +
</pre>
   
 
For other MUAs this has to be fitted. However, now, when your quoted email is displayed, you can use this Vim sequence to fix it:
 
For other MUAs this has to be fitted. However, now, when your quoted email is displayed, you can use this Vim sequence to fix it:
  +
*Move cursor to first line of broken paragraph.
 
1. Move cursor to first line of broken paragraph.
+
*Press 'V' and move to the last line of the paragraph you want to fix.
 
*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.
 
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.
 
   
 
==Comments==
 
==Comments==
You can also simply use the { and } paragraph motions in conjunction with 'gq'. For example, move to the top of a paragraph using {, then hit gq} to reformat it.
+
You can also simply use the <tt>{</tt> and <tt>}</tt> paragraph motions in conjunction with <tt>gq</tt>. For example, move to the top of a paragraph using <tt>{</tt>, then hit <tt>gq}</tt> to reformat it.
   
 
----
 
----
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.
+
Like just about everything else, <tt>gq</tt> will take any motion command. I find myself stepping through mails and random files with <tt>:set tw=72</tt> or whatnot and <tt>gqj</tt> and <tt>J</tt> and occasionally inserting stray <tt>></tt> characters.
   
 
----
 
----
 
The comments setting must contain the quoting character (usually '>'). So with
 
The comments setting must contain the quoting character (usually '>'). So with
  +
<pre>
set comments=s1:/*,mb:*,ex:*/,://,b:#,:%,:XCOMM,n:>,fb:-
+
set comments=s1:/*,mb:*,ex:*/,://,b:#,:%,:XCOMM,n:>,fb:-
  +
</pre>
  +
 
everything works as described.
 
everything works as described.
   

Revision as of 02:58, 4 December 2009

Tip 273 Printable Monobook Previous Next

created 2002 · complexity basic · version 5.7


When using Vim as your editor of choice, even for email processing - as I do - it is often unpleasing how some MUAs quote the email body produced by mailers such as Outlook. The lines often span across multiple visual lines and it's 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 MUAs this has to be fitted. However, now, when your quoted email is displayed, you can use this Vim sequence to fix it:

  • Move cursor to first line of broken paragraph.
  • Press 'V' and move to the last line of the paragraph you want to fix.
  • 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.

Comments

You can also simply use the { and } paragraph motions in conjunction with gq. For example, move to the top of a paragraph using {, then hit gq} to reformat it.


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 > characters.


The comments setting must contain the quoting character (usually '>'). So with

set comments=s1:/*,mb:*,ex:*/,://,b:#,:%,:XCOMM,n:>,fb:-

everything works as described.


See also Brian Medley's email ftplugin that does a very nice job on this issue.