Is it possible to paste in insert mode in Vim?
12 Answers
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
-
17Yep, I only recently learned of CTRL-R and it's extremely useful. – Dan May 20 '10 at 16:36
-
21`CTRL-R *` only works in GVIM or versions that are compiled to interact with x. Type `vim --version` and look for `+xterm_clipboard`. If you don't have that, you need a different version of vim. (http://vim.wikia.com/wiki/Accessing_the_system_clipboard) – Conrad.Dean Sep 26 '11 at 05:11
-
11You actually only need `+clipboard`, but if you have `+xterm_clipboard` you should have that anyway. On some OSs `xterm_clipboard` isn't applicable. – Andrew Marshall Mar 13 '12 at 02:42
-
1Hmm, I use C-r+ to paste from system clipboard on Windows (using GVim portable)? Never heard of * register. – kitsu.eb Sep 08 '12 at 14:28
-
6@kitsu.eb On X systems `*` register is pastable with middle-mouse-click while `+` is the traditional copy/paste. http://standards.freedesktop.org/clipboards-spec/clipboards-latest.txt – Feb 21 '13 at 06:42
-
why did i have to scroll so far to see this answer; i almost gave up – c.. Nov 15 '21 at 11:26
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.

- 30,738
- 21
- 105
- 131

- 3,992
- 2
- 20
- 16
-
1
-
49
-
1@Tech4Wilco for the record, if you prepend `no` to any almost any setting it'll disable it: `:set noexpandtab` and `:set expandtab` are opposite of each other. – TankorSmash Oct 04 '12 at 04:23
-
27@JamesSnyder A better way is `:set paste!` Probably set paste is very close in your command history, so you can simply press ':', then arrow-up and add a '!'. – Rafael Barbosa Nov 30 '12 at 13:51
-
6Just curious - what is better or different about `:set paste!` Thanks :) – Michael Durrant May 11 '13 at 13:03
-
38the `!` at the end of the command in `vim` toggles the command on and off. This way you don't have to type `:set nopaste` instead you could scroll up through your history and run the same command (`:set paste!`) again. – 에이바바 Sep 09 '13 at 16:47
-
1`set paste` messed up a lot of things in my vim setup. New lines were not indented properly, completion quit working. ♂️ – blockloop Oct 12 '17 at 22:19
-
3@blockloop You're supposed to enable it while pasting and disable it right afterwards. – Maya Sep 16 '18 at 11:59
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.
-
2
-
4
-
-
6Definitely faster than `esc + p + i` and definitely easier to type than `CTRL-R + "` – lucidbrot Jan 31 '18 at 08:15
-
Actually, this sometimes behaves differently from `CTRL-R "`. For instance, although vimrc settings can change this, pasting something in a new line using `CTRL-O p` makes its indentation go away. – noname Feb 28 '18 at 05:26
-
I agree with the answer, and wanna add that `Ctrl-o` brings you into Normal Insert Mode where you can fire *one* normal mode command, and in this case that command was `Ctrl-p` – William Kinaan Jun 08 '19 at 09:38
-
A problem with this approach I haven’t seen mentioned here is that when you paste while in insert mode (mentioned as the accepted answer), that will be part of the edit you’re making that you can redo when you use `.`, while with this approach, you interrupt editing and paste, which might mess up your flow if you’re trying to use `.` to repeat your action. – arg20 May 19 '20 at 00:52
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

- 46,476
- 14
- 84
- 101
-
11This answer seems to be the most comprehensive. It's very clear, and in my opinion, the most helpful. It answers the OP's question and then some, concisely. – Devvyn Mar 19 '15 at 17:29
You can use this to paste from clipboard with Ctrlv:
set pastetoggle=<F10>
inoremap <C-v> <F10><C-r>+<F10>
And this for yanking visual selection into clipboard with Ctrlc:
vnoremap <C-c> "+y
If you also want to use clipboard by default for classic vim yanking/pasting (y/p) in normal mode, here is a config option that does it:
set clipboard=unnamedplus
With this configs you can e.g. yank first in normal mode and then paste with Ctrlv in insert mode. Also, you can paste text from different vim instances and different applications.
Another option is:
set clipboard=unnamed
Then you will be able to just select something by mouse dragging in your X environment and paste it into vim afterwards. But (for some reason) you won't be able to yank something (y) in Vim and shiftinsert it somewhere else afterwards, which is probably quite limiting.
Vim docs about this: http://vim.wikia.com/wiki/Accessing_the_system_clipboard
For pasting from custom registers you can follow the other answers :). This answer is mainly about integrating Vim with your system clipboard.
Note that for set clipboard=unnamedplus
and set clipboard=unnamed
to work, you need to use gvim or vimx (vim-X11
): Those are compiled with +xterm_clipboard
. You can optionally put this into your .bashrc
to alias vim
with vimx
:
if [ -e /usr/bin/vimx ]; then
alias vim='/usr/bin/vimx'; # vim with +xterm_clipboard
fi
You can find out whether or not your vim has the +xterm_clipboard
in the information provided by vim --version
.

- 8,695
- 10
- 61
- 82
-
8This is exactly what I was looking for. It is also the only reasonable answer here. This is how one expects things to work. Does anyone know why the default behaviour of `:set paste` and the byzantine `
– Aeschylus Aug 13 '13 at 20:42* y` is even remotely desirable? Not to sound too committed, I am genuinely curious what vim philosophy this reflects, or if it is just a historical misfortune. -
Your answer allowed me to use Shift+Insert in Gvim also with `inoremap
+ ` (I use F12 as pastetoggle). Thanks.
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-combination (Ctrl + Insert is the corresponding 'copy').

- 30,738
- 21
- 105
- 131

- 231
- 1
- 2
-
1
-
-
Before using `Shift + Insert` to paste the text, we need to be in the insert mode. – jdhao Sep 07 '18 at 07:32
You can also use the mouse middle button to paste in insert mode (Linux only).

- 30,738
- 21
- 105
- 131

- 1,578
- 14
- 13
-
118
-
23
-
-1: This answer is highly dependent on hardware and terminal settings. Ultimately, the buttons on the mouse sends a preset strings to terminal, and terminal parses that string to execute a certain command. Problem is, this can vary greatly, depending on the terminal settings. To improve this answer, please provide us with, at least, version of terminal, OS, and version and model of mouse you're using. – melvynkim May 19 '14 at 23:57
-
Middle mouse button paste is pretty common across all Linux applications, not limited by terminal or OS versions. – lcltj May 21 '14 at 00:21
-
-
@ Jim Mitchener - A "mouse" is an ancient computing peripheral invented many many decades ago. It's probably from before your time. I always thought the mouse was a pretty neat idea, but it seems to have fallen out of favor at some point. – Steven Byks Apr 27 '17 at 15:06
-
You can enter -- INSERT (past) --
mode via:
- Keyboard combo: y p
or
:set paste
and entering insert mode (:set nopaste
to disable)
once in -- INSERT (past) --
mode simply use your systems paste function (e.g. CtrlShiftv on Linux, Cmdv on Mac OS).
This strategy is very usefully when using vim over ssh.

- 8,021
- 9
- 50
- 80
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.

- 12,241
- 27
- 68
- 82

- 7,871
- 1
- 22
- 23
-
Can I upvote more than once?? I only want to paste when I've come from another window - so I'm always on the mouse. Brilliant! – dave Aug 28 '12 at 09:35
-
In Linux you paste with pressing middle mouse button. If you have two button mouse and press both left and right button, then it needs "Emulate3Buttons" or similar to work this way. – Cougar Feb 05 '13 at 11:51
Just add map:
" ~/.vimrc
inoremap <c-p> <c-r>*
restart vim and when press Crtl+p
in insert mode,
copied text will be pasted

- 17,415
- 4
- 65
- 64
-
Love this, but I used `
0` to paste the main register contents (i.e. from yank) – antfx Feb 17 '23 at 09:27
Paste in Insert Mode
A custom map seems appropriate in this case. This is what I use to paste yanked items in insert mode:
inoremap <Leader>p <ESC>pa
My Leader
key here is \
; this means hitting \p
in insert mode would paste the previously yanked items/lines.

- 73,588
- 21
- 168
- 215
Add this to vimrc or init file:
imap <silent> PP <ESC>pa
..to paste in insert mode with "PP" and stay in insert mode..

- 31
- 7