Ubuntu has this feature that copy a file and pasting it into a text field pastes its path in the text field. Good. But how to do to that in Vim (launched using vim -g after installing vim-gtk) both in insert (for opening the file :e /file/path) and normal mode?

I tried :e Ctrl-r * but pasted text that I had copied earlier somewhere else. I tried it on Emacs Ctrl-y and in the address bar of Firefox Ctrl-v, it worked as expected.

  • Are any of the proposed answers so far coming close to what you are asking? By the way, pasting text after :e is called command mode. Insert mode is when editing the buffer. So are you asking for how to paste while in command mode, insert mode, normal mode, or all of the above? – Mike Miller May 30 '14 at 4:07
  • LiveWireBT's worked in normal mode. I'm looking for pasting in command mode. Insert mode would be appreciated. – Bleeding Fingers May 30 '14 at 5:11

You can use following shortcuts:

For copying text:


To paste:


  • Nope. Doesn't work. The paste key combination in insert mode adds ^ (seems similar to Emacs C-q). And in normal mode enters into visual mode. – Bleeding Fingers May 29 '14 at 16:44

By vim-gtk do you mean gvim?

(Because I tried installing the vim-gtk package in 14.04 and when I ran vim.gtk from terminal it didn't launch GVIM but vim instead)


  • To copy from GVIM to the clipboard use: "+y

    (Shift+2+y on a QWERTZ keyboard)

  • To paste from the clipborad to GVIM use: "+gP

    (Shift+2+gShift+p on a QWERTZ keyboard)

I haven't really used vim or GVIM yet, but a coworker is using it (on Windows...). "+ seems to be specific to visual commands and should work with vim specific commands like yw, y$, 10Y and so forth.

vim running in Gnome Terminal

To paste from clipboard enter insert mode with Shift+i and paste with Ctrl+Shift+v. Hit Esc to leave the insert mode.

Ctrl+Shift+c and Ctrl+Shift+v are general commands to copy and paste text from Gnome Terminal to the clipboard, but I think you already knew that.

I'm sure that real vim users would come up with more elegant solutions. As I said, I just installed GVIM and dug through the menus. (I tried using vim before, but always was lazy and went back to nano.)

  • 1
    I ran it with vim -g – Bleeding Fingers May 29 '14 at 12:31
  • The paste command works. Not sure what the one in braces does because after I typed @ + I had the path in the command-line (minibuffer in Emacs lingo) furthering typing g P appended gp to the path hitting enter there after raised the Pattern not found error. Question updated. I need to paste it insert mode. Thanks a lot though. – Bleeding Fingers May 29 '14 at 16:59
  • The ones in braces should be the same, but may be not as I'm using a QWERTZ keyboard. Can you look in the GVIM edit menu if your's are different? – LiveWireBT May 29 '14 at 17:16
  • Forgive my ignorance. What are you exactly asking me to check under the edit menu? It says paste is bound to "+gP. And it doesn't state which Keymap is active. – Bleeding Fingers May 29 '14 at 17:42
  • No no, everything is fine. Sorry for causing this confusion. – LiveWireBT May 29 '14 at 18:06

Vim has two registers for interacting with X text selection and clipboard. In your question you mention that you tried the "* register, but there is another register for yanking to and putting from the X clipboard, namely "+. As long as vim is built with X11 support (which the vim-gtk package has), both vim and gvim use these two registers for working with the X selection and clipboard buffers. Use the "* register if you want to paste text that has been highlighted with the mouse and use "+ to paste text that has been copied to the clipboard from another program.

Paste from the clipboard in normal mode

To paste from the X clipboard into a vim buffer while in normal mode, use "+p, "+P, "+gp, or "+gP depending on whether you want the text to be inserted before or after the cursor location and where you want the cursor to end up after pasting. See :help put in vim.

Paste from the clipboard in insert mode

If you are in insert mode in a vim buffer and want to paste the contents of the clipboard, use Ctrl+r and +. This will insert the clipboard text at the cursor location and keep you in insert mode to continue entering text after what was pasted. See :help i_CTRL-R in vim.

Paste from the clipboard in command mode

Pasting from the clipboard in command mode (while entering commands after :) is exactly the same as in insert mode, use Ctrl+r followed by +. So, referring to your original example of copying a file name in the system's file browser, you could open that file in vim by starting the command :e, then Ctrl+r, and then + to paste the file name. See :help c_CTRL-R in vim.

Vim has a large set of registers, some of which are general purpose for the user, and some of which have specific functions. For more information about Vim registers in general, see :help registers in Vim's manual. For more about the difference between the X selection and clipboard buffers, see :help x11-selection. And the specific uses of the "* and "+ registers are described in :help quotestar and :help quoteplus.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.