0

Possible Duplicate:
Vim - paste in insert mode?

I have, among others, two mappings:

vnoremap <C-X> "+x
inoremap <C-V> <C-O>"+P

Using that I can select and insert text like in any other editor, but one thing is weird: when the cursor is at the line end, text is being inserted before the last character, not after the last one as expected. Assuming the clipboard contains x. Cursor is at |. In Insert mode:

^|ab$   yields: ^x|ab$   expected: ^x|ab$
^a|b$           ^ax|b$             ^ax|b$
^ab|$           ^axb|$             ^abx|$

When I change the mapping to <C-O>"+p I have the same problem at line start, I guess this is due to the <C-O> which changes the cursor to a block cursor that can't be placed before start/after end.

So: how can I insert text before the insert mode cursor, using <C-V>, without having to call a function that calls p or P depending on the position in the line, which would be the only thing I can think of?

Community
  • 1
  • 1
pascal
  • 2,623
  • 2
  • 20
  • 30

1 Answers1

1

First related question. Duh.

inoremap <C-V> <C-R>"

Inserts contents of register " before the cursor in insert mode just like I wanted it.

Community
  • 1
  • 1
pascal
  • 2,623
  • 2
  • 20
  • 30