Paste in insert mode?
While in insert mode hit CTRL-R {register}
Examples:
CTRL-R *
will insert in the contents of the clipboardCTRL-R "
(the unnamed register) inserts the last delete or yank.
To find this in vim's help type :h i_ctrl-r
While in insert mode, you can use Ctrl-R {register}
, where register can be:
+
for the clipboard,*
for the X clipboard (last selected text in X),"
for the unnamed register (last delete or yank in Vim),- or a number of others (see
:h registers
).
Ctrl-R {register}
inserts the text as if it were typed.
Ctrl-R Ctrl-O {register}
inserts the text with the original indentation.
Ctrl-R Ctrl-P {register}
inserts the text and auto-indents it.
Ctrl-O
can be used to run any normal mode command before returning to insert mode, so Ctrl-O "+p
can also be used, for example.
For more information, view the documentation with :h i_ctrl-r
If you don't want Vim to mangle formatting in incoming pasted text, you might also want to consider using: :set paste
. This will prevent Vim from re-tabbing your code. When done pasting, :set nopaste
will return to the normal behavior.
It's also possible to toggle the mode with a single key, by adding something like set pastetoggle=<F2>
to your .vimrc. More details on toggling auto-indent are here.
No not directly. What you can do though is quickly exit insert mode for a single normal mode operation with Ctrl-O and then paste from there which will end by putting you back in insert mode.
Key Combo: Ctrl-O p
EDIT: Interesting. It does appear that there is a way as several other people have listed.