1

I'm trying to migrate from Windows to Linux and am having difficulties with the shortcuts in gvim.

For something as simple a copying you press "+y and I'm wondering

1)does order matter when pressing the buttons? I already found you don't need to hold down all 4 (including shift) keys at once

2)is there a simpler shortcut or a way to change this one?

3)why on Earth did the makers choose these keys to mean copy?

3

First, Vim doesn't support chording, i.e. pressing several keys simultaneously. It's only one main key, plus a possible combination of modifier keys (i.e. Shift, Ctrl, Alt). So, you'd type ", then +, then y when you read "+y.


For stuff that you do frequently, there's a shortcut mechanism, called mappings. For example, to use F2 instead:

:nnoremap <F2> "+y

You'll need to understand the modes of Vim. :help map.txt has all the information. If you just want mappings like most Windows applications (e.g. Ctrl+C for copy), add

:runtime mswin.vim

to your ~/.vimrc, and you're done.


Why is "+y so difficult? Well, usually you use Vim's internal registers, mostly the unnamed register, and that's the quick and easy y. Vim is often used in the terminal or through an SSH connection, so interacting with the system's clipboard is not that common.

0

I'm using system clipboard in vim. That means

  • Anything yanked by y / Y / x / X / d /.., will write to system clipboard.
  • And also, anything was copied by ctrl+c or something, will be pasted to vim by p / P / ...

The setting as below:

if has('win32') || has('win95') || has('win64')
    set clipboard+=unnamed
    set clipboard+=unnamedplus
else
    set clipboard=unnamedplus

More details can be found at http://vim.wikia.com/wiki/Accessing_the_system_clipboard and http://vim.wikia.com/wiki/VimTip21

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.