Browse files

Add repeat.vim support for e and <Space>

  • Loading branch information...
1 parent 1fec2a3 commit 5e172144646ad2b8d9d126f6de50683418b1dd2c @tpope committed Sep 10, 2011
Showing with 25 additions and 6 deletions.
  1. +25 −6 plugin/unimpaired.vim
@@ -102,16 +102,35 @@ omap ]> V:call search('^>>>>>>>','W')<CR>
" }}}1
" Line operations {{{1
-nnoremap <silent> <Plug>unimpairedBlankUp :<C-U>put!=repeat(nr2char(10),v:count)<Bar>']+1<CR>
-nnoremap <silent> <Plug>unimpairedBlankDown :<C-U>put =repeat(nr2char(10),v:count)<Bar>'[-1<CR>
+function! s:BlankUp(count) abort
+ put!=repeat("\n", a:count)
+ ']+1
+ call repeat#set("\<Plug>unimpairedBlankUp", a:count)
+function! s:BlankDown(count) abort
+ put =repeat("\n", a:count)
+ '[-1
+ call repeat#set("\<Plug>unimpairedBlankDown", a:count)
+nnoremap <silent> <Plug>unimpairedBlankUp :<C-U>call <SID>BlankUp(v:count1)<CR>
+nnoremap <silent> <Plug>unimpairedBlankDown :<C-U>call <SID>BlankDown(v:count1)<CR>
nmap [<Space> <Plug>unimpairedBlankUp
nmap ]<Space> <Plug>unimpairedBlankDown
-nnoremap <silent> <Plug>unimpairedMoveUp :<C-U>exe 'norm! m`'<Bar>exe 'move--'.v:count1<Bar>norm! ``<CR>
-nnoremap <silent> <Plug>unimpairedMoveDown :<C-U>exe 'norm! m`'<Bar>exe 'move+'.v:count1<Bar>norm! ``<CR>
-xnoremap <silent> <Plug>unimpairedMoveUp :<C-U>exe 'norm m`'<Bar>exe '''<,''>move--'.v:count1<CR>``
-xnoremap <silent> <Plug>unimpairedMoveDown :<C-U>exe 'norm m`'<Bar>exe '''<,''>move''>+'.v:count1<CR>``
+function! s:Move(cmd, count, map) abort
+ normal! m`
+ exe 'move'.a:cmd.a:count
+ norm! ``
+ call repeat#set("\<Plug>unimpairedMove".a:map, a:count)
+nnoremap <silent> <Plug>unimpairedMoveUp :<C-U>call <SID>Move('--',v:count1,'Up')<CR>
+nnoremap <silent> <Plug>unimpairedMoveDown :<C-U>call <SID>Move('+',v:count1,'Down')<CR>
+xnoremap <silent> <Plug>unimpairedMoveUp :<C-U>exe 'normal! m`'<Bar>exe '''<,''>move--'.v:count1<CR>``
+xnoremap <silent> <Plug>unimpairedMoveDown :<C-U>exe 'normal! m`'<Bar>exe '''<,''>move''>+'.v:count1<CR>``
nmap [e <Plug>unimpairedMoveUp
nmap ]e <Plug>unimpairedMoveDown

4 comments on commit 5e17214

vxsx replied Sep 10, 2011

And if I don't have repeat.vim installed it now raises error "unknown function: repeat#set"


tpope replied Sep 10, 2011

Whoops! Fixed, thanks.

Though really, you should have repeat.vim installed. :)

vxsx replied Sep 10, 2011

Installed already, thank you)

I copied just the BlankUp/BlankDown functions and their mappings into my .vimrc. Works great, but now every time I hit 'undo' I get about 1sec of lag before it actually undoes. Removing these functions speeds it back up. I'm not using the version from this commit, I'm using the version from the current master (as of 2/20/2013).

Please sign in to comment.