aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2018-08-08 13:16:56 +1200
committerTom Ryder <tom@sanctum.geek.nz>2018-08-08 13:16:56 +1200
commit6ad8bfc39501fe74708899734c16d89bc8241ada (patch)
tree999e0887c3139cd43ebbef19506d16d18a52f05c
parentffaa0071e0e865701656c3d3ebe2115c25de5725 (diff)
downloaddotfiles-6ad8bfc39501fe74708899734c16d89bc8241ada.tar.gz
dotfiles-6ad8bfc39501fe74708899734c16d89bc8241ada.zip
Improve ,[ and ,] mappings in mail
-rw-r--r--vim/after/ftplugin/mail.vim23
1 files changed, 19 insertions, 4 deletions
diff --git a/vim/after/ftplugin/mail.vim b/vim/after/ftplugin/mail.vim
index e7548b3c..66064401 100644
--- a/vim/after/ftplugin/mail.vim
+++ b/vim/after/ftplugin/mail.vim
@@ -63,14 +63,29 @@ nnoremap <buffer>
let b:undo_ftplugin .= '|nunmap <buffer> <LocalLeader>l'
" Maps to move to the next blank line content-wise (i.e. quoted still counts)
+function! s:NewBlank(num, up) abort
+ let l:num = a:num
+ let l:par = 0
+ while l:num <= line('$')
+ if getline(l:num) =~# '^[ >]*$'
+ if l:par
+ break
+ endif
+ else
+ let l:par = 1
+ endif
+ let l:num += a:up ? -1 : 1
+ endwhile
+ execute l:num
+endfunction
nnoremap <buffer> <silent> <LocalLeader>[
- \ :<C-U>call search('\m^[ >]*$', 'bW')<CR>
+ \ :<C-U>call <SID>NewBlank(line('.'), 1)<CR>
nnoremap <buffer> <silent> <LocalLeader>]
- \ :<C-U>call search('\m^[ >]*$', 'W')<CR>
+ \ :<C-U>call <SID>NewBlank(line('.'), 0)<CR>
onoremap <buffer> <silent> <LocalLeader>[
- \ :<C-U>call search('\m^[ >]*$', 'bW')<CR>
+ \ :<C-U>call <SID>NewBlank(line('.'), 1)<CR>
onoremap <buffer> <silent> <LocalLeader>]
- \ :<C-U>call search('\m^[ >]*$', 'W')<CR>
+ \ :<C-U>call <SID>NewBlank(line('.'), 0)<CR>
let b:undo_ftplugin .= '|nunmap <buffer> <LocalLeader>['
\ . '|nunmap <buffer> <LocalLeader>]'
\ . '|ounmap <buffer> <LocalLeader>['