I wrote a function for automizing my signature proceeding.
Unfortunately my former macros (append signature and kill signature) don't
seem to work within my function anymore.
My kill signature macro used to be:
map ,ks G?^[> ]*-- $<CR>dG
Whereas to append signatures I wrote this one:
map ,as mXGo-- <CR><Esc>:.!fortune fortunes-o<CR>`X
At first, I intended to combine those two, resulting in one big super macro
looking for a signature, and replacing it with a new one.
If no signature can be found, one simply should be added. Unfortunately, I
didn't succeed with this, so I began writing a function.
As I'm still quite a beginner in vim customization, I immediately ran into
let sig = 0
" the following will show an annoying message in vim's status bar if the
" regex does not match, but how may we avoid this?
%g/^[> ]*-- /let sig = 1
if sig == 0
" Let's attach a random signature
$put =\"-- \"
" The following line needs a manual return (annoying!) and
" 'eats up' the preceding line, ie. our 2nd $put=... stuff, dunno
" BTW, the sole purpose of the 2nd $put=... is to make sure that our
" "-- " line above is kept!
" Is there a better way of filtering the fortune output, without
let sig = 1
" It seems that an obsolete signature (quoted or even non quoted)
" is already there, so first, we'll have to remove it, sorta like:
" 'dG', starting within the pattern's line ("^[> ]*-- $")
" < the command goes here! >
" afterwards, append our new signature like above
$put =\"-- \"
map ,sig <Esc>:call Sig()<CR>
+++ GMX - Mail, Messaging & more http://www.gmx.net
NEU: Mit GMX ins Internet. Rund um die Uhr für 1 ct/ Min. surfen!