.vim/ftplugin/mail.vim

changeset 411
1bb7fe33cd74
parent 387
d16b5c66461a
child 434
be837354e11b
equal deleted inserted replaced
410:7f1e71910dc6 411:1bb7fe33cd74
1 setl textwidth=72 1 setl textwidth=72
2 setl formatoptions=jaw12tcql 2 setl formatoptions=jaw12tcql
3 setl spell 3 setl spell
4
5 " http://cedricduval.free.fr/download/mail.vim
6 function! Mail_Erase_Sig()
7 " search for the signature pattern (takes into account signature delimiters
8 " from broken mailers that forget the space after the two dashes)
9 let i = 0
10 while ((i <= line('$')) && (getline(i) !~ '^> *-- \=$'))
11 let i = i + 1
12 endwhile
13
14 " if found, then
15 if (i != line('$') + 1)
16 " first, look for our own signature, to avoid deleting it
17 let j = i
18 while (j < line('$') && (getline(j + 1) !~ '^-- $'))
19 let j = j + 1
20 endwhile
21
22 " second, search for the last non empty (non sig) line
23 while ((i > 0) && (getline(i - 1) =~ '^\(>\s*\)*$'))
24 let i = i - 1
25 endwhile
26
27 " third, delete those lines plus the signature
28 exe ':'.i.','.(j - 1).'d'
29 endif
30 endfunction
31
32 call Mail_Erase_Sig()
4 33
5 " Get right to composing the body: 34 " Get right to composing the body:
6 if line('$') > 1 35 if line('$') > 1
7 :0 36 :0
8 :/^$/ 37 :/^$/
9 :normal 2] 38 :normal 2]
10 :+1 39 :+1
11 :exe 'startinsert' 40 :exe 'startinsert'
12 endif 41 endif
13

mercurial