As I understand it, the problem is that your plugin will do an operation which leaves the "dot" repeat command in an inconsistent state. From the question, I don't know what this operation is, but generally you can re-structure your plugin in a way that it will work as expected.
You can use the g@
operator feature to run arbitrary commands which are repeatable. The following is an example using wincmd
, however you can replace this with another command or function call.
This is a completely native method which should be preferred to e.g., vim-repeat which require re-mapping the dot command.
function! RepWincmd(...)
execute (v:count ? v:count : s:rep[1]) 'wincmd' s:rep[0]
endfunction
function! s:setup(rep, ...)
let s:rep = [a:rep, v:count ? v:count : get(a:000, 0, 1)]
set operatorfunc=RepWincmd
return 'g@l'
endfunction
" optional number is the default shift amount
nnoremap <expr> <c-w>- <sid>setup('-', 3)
nnoremap <expr> <c-w>+ <sid>setup('+', 3)
nnoremap <expr> <c-w>< <sid>setup('<', 5)
nnoremap <expr> <c-w>> <sid>setup('>', 5)
:h registers
confirms this). Can you achieve your plugin's aim a different way?<cmd>
to not change the mode?C-O
shouldn't be there then. Cause<cmd>
was introduced exactly for this.