.vim/ftplugin/mail.vim

Sat, 17 Dec 2016 23:47:41 -0500

author
Meredith Howard <mhoward@roomag.org>
date
Sat, 17 Dec 2016 23:47:41 -0500
changeset 450
4865de0a8b7a
parent 434
be837354e11b
child 504
e4e09e3317ec
permissions
-rw-r--r--

sidescrolloff

387
d16b5c66461a fix formatoptions and autorun
Meredith Howard <mhoward@roomag.org>
parents: 368
diff changeset
1 setl textwidth=72
d16b5c66461a fix formatoptions and autorun
Meredith Howard <mhoward@roomag.org>
parents: 368
diff changeset
2 setl formatoptions=jaw12tcql
d16b5c66461a fix formatoptions and autorun
Meredith Howard <mhoward@roomag.org>
parents: 368
diff changeset
3 setl spell
349
976c8bf0499b set reflow_wrap = wrap
Meredith Howard <mhoward@roomag.org>
parents: 348
diff changeset
4
411
1bb7fe33cd74 Add previous sig removal
Meredith Howard <mhoward@roomag.org>
parents: 387
diff changeset
5 " http://cedricduval.free.fr/download/mail.vim
1bb7fe33cd74 Add previous sig removal
Meredith Howard <mhoward@roomag.org>
parents: 387
diff changeset
6 function! Mail_Erase_Sig()
1bb7fe33cd74 Add previous sig removal
Meredith Howard <mhoward@roomag.org>
parents: 387
diff changeset
7 " search for the signature pattern (takes into account signature delimiters
1bb7fe33cd74 Add previous sig removal
Meredith Howard <mhoward@roomag.org>
parents: 387
diff changeset
8 " from broken mailers that forget the space after the two dashes)
1bb7fe33cd74 Add previous sig removal
Meredith Howard <mhoward@roomag.org>
parents: 387
diff changeset
9 let i = 0
1bb7fe33cd74 Add previous sig removal
Meredith Howard <mhoward@roomag.org>
parents: 387
diff changeset
10 while ((i <= line('$')) && (getline(i) !~ '^> *-- \=$'))
1bb7fe33cd74 Add previous sig removal
Meredith Howard <mhoward@roomag.org>
parents: 387
diff changeset
11 let i = i + 1
1bb7fe33cd74 Add previous sig removal
Meredith Howard <mhoward@roomag.org>
parents: 387
diff changeset
12 endwhile
1bb7fe33cd74 Add previous sig removal
Meredith Howard <mhoward@roomag.org>
parents: 387
diff changeset
13
1bb7fe33cd74 Add previous sig removal
Meredith Howard <mhoward@roomag.org>
parents: 387
diff changeset
14 " if found, then
1bb7fe33cd74 Add previous sig removal
Meredith Howard <mhoward@roomag.org>
parents: 387
diff changeset
15 if (i != line('$') + 1)
1bb7fe33cd74 Add previous sig removal
Meredith Howard <mhoward@roomag.org>
parents: 387
diff changeset
16 " first, look for our own signature, to avoid deleting it
1bb7fe33cd74 Add previous sig removal
Meredith Howard <mhoward@roomag.org>
parents: 387
diff changeset
17 let j = i
1bb7fe33cd74 Add previous sig removal
Meredith Howard <mhoward@roomag.org>
parents: 387
diff changeset
18 while (j < line('$') && (getline(j + 1) !~ '^-- $'))
1bb7fe33cd74 Add previous sig removal
Meredith Howard <mhoward@roomag.org>
parents: 387
diff changeset
19 let j = j + 1
1bb7fe33cd74 Add previous sig removal
Meredith Howard <mhoward@roomag.org>
parents: 387
diff changeset
20 endwhile
1bb7fe33cd74 Add previous sig removal
Meredith Howard <mhoward@roomag.org>
parents: 387
diff changeset
21
1bb7fe33cd74 Add previous sig removal
Meredith Howard <mhoward@roomag.org>
parents: 387
diff changeset
22 " second, search for the last non empty (non sig) line
1bb7fe33cd74 Add previous sig removal
Meredith Howard <mhoward@roomag.org>
parents: 387
diff changeset
23 while ((i > 0) && (getline(i - 1) =~ '^\(>\s*\)*$'))
1bb7fe33cd74 Add previous sig removal
Meredith Howard <mhoward@roomag.org>
parents: 387
diff changeset
24 let i = i - 1
1bb7fe33cd74 Add previous sig removal
Meredith Howard <mhoward@roomag.org>
parents: 387
diff changeset
25 endwhile
1bb7fe33cd74 Add previous sig removal
Meredith Howard <mhoward@roomag.org>
parents: 387
diff changeset
26
1bb7fe33cd74 Add previous sig removal
Meredith Howard <mhoward@roomag.org>
parents: 387
diff changeset
27 " third, delete those lines plus the signature
1bb7fe33cd74 Add previous sig removal
Meredith Howard <mhoward@roomag.org>
parents: 387
diff changeset
28 exe ':'.i.','.(j - 1).'d'
1bb7fe33cd74 Add previous sig removal
Meredith Howard <mhoward@roomag.org>
parents: 387
diff changeset
29 endif
1bb7fe33cd74 Add previous sig removal
Meredith Howard <mhoward@roomag.org>
parents: 387
diff changeset
30 endfunction
1bb7fe33cd74 Add previous sig removal
Meredith Howard <mhoward@roomag.org>
parents: 387
diff changeset
31
1bb7fe33cd74 Add previous sig removal
Meredith Howard <mhoward@roomag.org>
parents: 387
diff changeset
32 call Mail_Erase_Sig()
1bb7fe33cd74 Add previous sig removal
Meredith Howard <mhoward@roomag.org>
parents: 387
diff changeset
33
387
d16b5c66461a fix formatoptions and autorun
Meredith Howard <mhoward@roomag.org>
parents: 368
diff changeset
34 " Get right to composing the body:
d16b5c66461a fix formatoptions and autorun
Meredith Howard <mhoward@roomag.org>
parents: 368
diff changeset
35 if line('$') > 1
434
be837354e11b simplify mail autoinsert, disable cursor autojump for mail
Meredith Howard <mhoward@roomag.org>
parents: 411
diff changeset
36 :normal gg}o
be837354e11b simplify mail autoinsert, disable cursor autojump for mail
Meredith Howard <mhoward@roomag.org>
parents: 411
diff changeset
37 :startinsert
387
d16b5c66461a fix formatoptions and autorun
Meredith Howard <mhoward@roomag.org>
parents: 368
diff changeset
38 endif

mercurial