Vim Tips Wiki
(Change to TipImported template + severe manual clean)
(Move categories to tip template)
Line 9: Line 9:
 
|version=5.7
 
|version=5.7
 
|rating=-1/1
 
|rating=-1/1
  +
|category1=Email
  +
|category2=
 
}}
 
}}
 
I frequently get email from people who do not use format-flowed email properly. I prefer to send out "correct" email, including the stuff I'm quoting, and Vim helps me do that. I added this function to my vimrc, and now I use it when editing mail by simply typing:
 
I frequently get email from people who do not use format-flowed email properly. I prefer to send out "correct" email, including the stuff I'm quoting, and Vim helps me do that. I added this function to my vimrc, and now I use it when editing mail by simply typing:
Line 43: Line 45:
   
 
----
 
----
[[Category:Email]]
 

Revision as of 05:01, 25 April 2008

Tip 948 Printable Monobook Previous Next

created June 8, 2005 · complexity intermediate · author Kyle Wheeler · version 5.7


I frequently get email from people who do not use format-flowed email properly. I prefer to send out "correct" email, including the stuff I'm quoting, and Vim helps me do that. I added this function to my vimrc, and now I use it when editing mail by simply typing:

:call FixFlowed()

That's easier to type, because I really type :call F<tab>

Here's the function:

function! Fixflowed()
  " save cursor position
  let pos = getpos(".")[1:]
  " add spaces to the end of every line
  silent! %s/\([^]> :]\)\ze\n>[> ]*[^> ]/\1 /g
  " fix the wockas spacing from the text
  silent! %s/^[> ]*>\ze[^> ]/& /
  " compress the wockas
  while search('^>\+ >', 'w') > 0
    s/^>\+\zs >/>/
  endwhile
  " restore the original cursor location
  call cursor(pos)
endfunction

It's a little sensitive because it blows away ascii art, and it also doesn't automatically reflow paragraphs (I have no idea how to do that properly). Hope it helps someone.

Comments

PAR is a lot better at this kind of thing: http://www.nicemice.net/par/