Skip to content

Commit 5bc3b40

Browse files
committed
squash! Add support for repeating previous/next commands
Use "normal" in b:unimpaired_prevnext explicitly. This allows to specify the whole command for :exe, and does not require a mapping. The mapping is used internally to handle the "zv", but that could be included in the command already now.
1 parent 7b75268 commit 5bc3b40

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

plugin/unimpaired.vim

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ function! s:MapNextFamily(map,cmd) abort
3636
let map = '<Plug>unimpaired'.toupper(a:map)
3737
let cmd = '".(v:count ? v:count : "")."'.a:cmd
3838
let end = '"<CR>'.(a:cmd == 'l' || a:cmd == 'c' ? 'zv' : '')
39-
let prevnext = printf('["\%sPrevious", "\%sNext"]', map, map)
39+
let prevnext = printf('["normal \%sPrevious", "normal \%sNext"]', map, map)
4040
execute 'nnoremap <silent> '.map.'Previous :<C-U>exe <SID>prevnext("'.a:cmd.'", "previous", '.prevnext.')<CR>'
4141
execute 'nnoremap <silent> '.map.'Next :<C-U>exe <SID>prevnext("'.a:cmd.'", "next", '.prevnext.')<CR>'
4242
execute 'nnoremap <silent> '.map.'First :<C-U>exe "'.cmd.'first'.end
@@ -82,7 +82,7 @@ function! s:last_prevnext_cmd(dir) abort
8282
endif
8383
return 'normal '.(a:dir ==# 'previous' ? '[' : ']').m
8484
endif
85-
return 'normal '.(a:dir ==# 'previous' ? prevnext[0] : prevnext[1])
85+
return (a:dir ==# 'previous' ? prevnext[0] : prevnext[1])
8686
endfunction
8787
execute 'nnoremap <silent> <Plug>unimpairedRepeatPrevious :<C-U>exe <SID>last_prevnext_cmd("previous")<CR>'
8888
execute 'nnoremap <silent> <Plug>unimpairedRepeatNext :<C-U>exe <SID>last_prevnext_cmd("next")<CR>'

0 commit comments

Comments
 (0)