Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

What would be the commands to be able to do CTRL + V on gVim?

In OS X I can copy text into vim, but on Windows I'm not getting.

share|improve this question

migrated from stackoverflow.com Dec 5 '11 at 11:53

This question came from our site for professional and enthusiast programmers.

4 Answers 4

up vote 0 down vote accepted

I would recommend to one of the following instead of setting up custom shortcuts:

  1. Paste from register:

    "+++p

  2. Paste using middle mouse button

  3. Paste using context menu

EDIT:

According to this answer you might need to have the clipboard set to unnamed to get register pasting to work.

set clipboard=unnamed

share|improve this answer
    
Only "+ p does not work in mac or win... –  Anderson Juhasc Dec 5 '11 at 15:44
    
@AndersonJuhasc according to this answer you might need to set clipboard=unnamed –  tidbeck Dec 5 '11 at 16:01
    
thanks tidbeck =) –  Anderson Juhasc Dec 5 '11 at 16:11

Add the following in your vimrc file (should be located under C:\Program Files\Vim\_vimrc):

" CTRL-X = cut
vnoremap <C-X> "+x
" CTRL-C = copy
vnoremap <C-C> "+y
" CTRL-V = paste
map <C-V> "+gP
cmap <C-V> <C-R>+
exe 'inoremap <script> <C-V>' paste#paste_cmd['i']
exe 'vnoremap <script> <C-V>' paste#paste_cmd['v']
imap <S-Insert> <C-V>
vmap <S-Insert> <C-V>

Or use the p command in vim to paste the content of the clipboard.

share|improve this answer
2  
... that is sooo wrong ... –  ldigas Dec 5 '11 at 0:09

From the vim documentation:

mswin.vim

To use the standard MS-Windows way of CTRL-X, CTRL-C and CTRL-V, use the $VIMRUNTIME/mswin.vim script. You could add this line to your _vimrc file: source $VIMRUNTIME/mswin.vim

share|improve this answer

While you can set up key bindings as Otiel suggests, I think it might be more useful to understand how copy and paste works in Vim, and learn what those commands actually mean.

The cut, copy and paste commands in Vim (d, y and p) work with so-called registers which hold the text last cut or copied. By default, they use the unnamed register "", while the system clipboard is the "+ register.

You can prefix commands with a register to that one instead. So, to copy from Vim to Windows, use "+y, and to paste from Windows, use "+p.

You also have 26 registers named "a to "z which you can use for anything you want. This can be very useful when doing complex editing operations.

There are more special registers as well, for more info, see :help registers.

share|improve this answer
    
Using '"+ y' in OSX? –  Anderson Juhasc Dec 5 '11 at 12:36

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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