What is the best way of linking the Ctrl-V key combination to pasting the clipboard in insert mode? I used
map <C-v> "+gP
imap <C-v> <C-r><C-p>+
in .vimrc
. However in insert mode, this definition sometimes doesn't work, it pasts the inserted text in a new line above the current cursor position.
Edit: I have a more detailed bug description now: The problem seems to appear when the String in the clip board terminates with a new line. Here a receipt to reproduce:
I open gvim
and a LibreOffice
word processor window. In LibreOffice I type
Hello Test
Foo bar
Then I select "Hello Test"+the line break (but not the 'F' of foo) and press Ctrl-c
. In Gvim I enter insertmode, Tyle Enter (new line), type 'some text', press Ctrl-v
. The Result will be that "Hello Test" is inserted in a new line above "some text" and the cursor is positioned at first char of the "some text" line.
If in LibreOffice I copy only "Hello Test" without the linebreak, the behavor is normaL ("Hello Test" will be inserted after "some text" and the cursor is right of the inserted string).
This problem is not specific to LibreOffice, it also happens when I copy paste full lines from PDF Files with okular
or acroread
. Generally it happens always when the copy pasted string terminates in newline.
Any ideas?
<C-p>
? I think that's what's causing your problem.:h i_CTRL-R_CTRL-P