tags:

views:

273

answers:

6

Is it possible to paste in insert mode in vim?

+1  A: 

EDIT

Interesting. It does appear that there is a way as several other people have listed.

No not directly. What you can do though is quickly enter 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

JaredPar
A: 

If you set vim to use the system clipboard (:set clipboard=unnamed), then any text you copy in vim can be pasted using Shift+Insert. Shift+Insert is simply an OS-wide paste key-combo (Ctrl+insert is the corresponding 'copy')

Will
+12  A: 

While in insert mode hit CTRL-R {register}. For example, CTRL-R * will insert in the contents of the clipboard and CTRL-R " (the unnamed register) inserts the the last delete or yank.

To find this in vim's help type :h i_ctrl-r

david
Yep, I only recently learned of CTRL-R and it's extremely useful.
Dan
A: 

Yes. In Windows Ctrl+V and in Linux pressing both mouse buttons nearly simultaneously.

In Windows I think this line in my _vimrc probably does it:

source $VIMRUNTIME/mswin.vim

In Linux I don't remember how I did it. It looks like I probably deleted some line from the default .vimrc file.

Windows programmer
A: 

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.

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 here.

James Snyder
A: 

You can also use mouse middle button to paste in insert mode.