Actually the solution is you have to go to command mode(e.g. Esc) first and re-enter the insert mode, but it only works if I type manually but it seems "randomly" stop working if I test it in ~/.vimrc
. Google doesn't help at all.
I spends a lot of time try to fix this issue and I just figure out the reason in my case:
Don't map the paste key same with the terminal existing paste key
e.g. Ctrl+Shift+V will paste in my Konsole terminal, but if I assign this key <C-S-v>
in ~/.vimrc
, the "undo for only single paste instead of multiple pastes" will not working.
In my case, I have to use <C-v>
instead of <C-S-v>
:
inoremap <C-v> <Esc>"+pi<Esc>i<Right><Right>
Your case may difference, but the point is same: don't assign the same paste key conflicts with existing terminal emulator key.
I've 100% proved this conclusion by set my terminal paste key to Ctrl+V and now <C-v>
stop working but <C-S-v>
working.
Note also that the vim is too sensitive and strange. I figure out I have to use i
and then 2 Right keys manually to make it works in the correct cursor position, that's means I have to put i
and 2 Right keys in the ~/.vimrc
too. Your case might difference, but the point is same, ensure the keys+order in ~/.vimrc 100% match with what you type manually.