I'm using imap <c-v> <ESC>"+PA
in gVIM to do the pasting , however , each time i tried to paste i got unexpected result:
aa${CURSOR}aa
, and press ^V right now , i got a${PASTE_TXT}aaa
, but i wanted aa${PASTE_TXT}aa
.
How can i fix this ?
I would suggest that you do not remap CTRL-V, it is really useful when you want to insert raw characters. In order to paste in insert mode, you needn't switch to normal mode. Use CTRL-R then CTRL-O, then +. That's not so long. You can remap an F-Key to do that:
:inoremap <F1> <C-r><C-o>+
or
:inoremap <C-v> <C-r><C-o>+
See :help i_CTRL-R
for more reference. You might also like this answer I gave about registers.
If you still want to keep your mapping using normal mode, replace P
with p
and A
with a
. After all you want to paste after the last character you have stopped when leaving insert mode, and to continue inserting after pasted text, not at end of line.
:inoremap <C-v> <Esc>"+pa
Change imap <c-v> <ESC>"+PA
to imap <c-v> <ESC>"+pA
Upper case P
is paste before cursor position, lower case p
is after cursor position.