From 49c6b781e09dbfd2844b10f2a1ee43f7eb2af142 Mon Sep 17 00:00:00 2001 From: Junegunn Choi Date: Tue, 25 Oct 2016 23:12:05 +0900 Subject: [PATCH] Do not prepend COUNT"REGISTER when feeding keys in insert mode Close #543 --- plug.vim | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/plug.vim b/plug.vim index c4c92e8..1017d47 100644 --- a/plug.vim +++ b/plug.vim @@ -257,8 +257,8 @@ function! plug#end() for [mode, map_prefix, key_prefix] in \ [['i', '', ''], ['n', '', ''], ['v', '', 'gv'], ['o', '', '']] execute printf( - \ '%snoremap %s %s:call lod_map(%s, %s, "%s")', - \ mode, map, map_prefix, string(map), string(names), key_prefix) + \ '%snoremap %s %s:call lod_map(%s, %s, %s, "%s")', + \ mode, map, map_prefix, string(map), string(names), mode != 'i', key_prefix) endfor endfor @@ -498,7 +498,7 @@ function! s:lod_cmd(cmd, bang, l1, l2, args, names) execute printf('%s%s%s %s', (a:l1 == a:l2 ? '' : (a:l1.','.a:l2)), a:cmd, a:bang, a:args) endfunction -function! s:lod_map(map, names, prefix) +function! s:lod_map(map, names, with_prefix, prefix) call s:lod(a:names, ['ftdetect', 'after/ftdetect', 'plugin', 'after/plugin']) call s:dobufread(a:names) let extra = '' @@ -510,15 +510,17 @@ function! s:lod_map(map, names, prefix) let extra .= nr2char(c) endwhile - let prefix = v:count ? v:count : '' - let prefix .= '"'.v:register.a:prefix - if mode(1) == 'no' - if v:operator == 'c' - let prefix = "\" . prefix + if a:with_prefix + let prefix = v:count ? v:count : '' + let prefix .= '"'.v:register.a:prefix + if mode(1) == 'no' + if v:operator == 'c' + let prefix = "\" . prefix + endif + let prefix .= v:operator endif - let prefix .= v:operator + call feedkeys(prefix, 'n') endif - call feedkeys(prefix, 'n') call feedkeys(substitute(a:map, '^', "\", '') . extra) endfunction