Add the following lines to your _vimrc or .vimrc

[pastacode lang=”javascript” manual=”source%20%24VIMRUNTIME%2Fmswin.vim%0Abehave%20mswin%0A” message=”javascript code” highlight=”” provider=”manual”/]
  • But beware, visual mode is then CTRL-Q instead of CTRL-V.
  • For an overview what mswin.vim does see the mswin.vim sourcode.
  • It is commented very well and if some command is unclear you can easily look it up in vim’s help
[ad type=”banner”]

Here is a quick overview compiled from the source:

  • backspace and cursor keys wrap to previous/next line
  • CTRL-X and SHIFT-Del are Cut
  • CTRL-C and CTRL-Insert are Copy
  • CTRL-V and SHIFT-Insert are Paste
  • Use CTRL-Q to do what CTRL-V used to do
  • Use CTRL-S for saving, also in Insert mode
  • CTRL-Z is Undo; not in cmdline though
  • CTRL-Y is Redo (although not repeat); not in cmdline though
  • Alt-Space is System menu
  • CTRL-A is Select all
  • CTRL-Tab is Next window
  • CTRL-F4 is Close window

we put following in  .gvimrc to show Ctrl-V besides Paste in the menu:

[pastacode lang=”bash” manual=”unmenu!%20Edit.Paste%0Aaunmenu%20Edit.Paste%0Annoremenu%2020.360%20%26Edit.%26Paste%3CTab%3ECtrl-V%20%20%20%20%09%22%2BgP%0Acnoremenu%20%20%20%20%26Edit.%26Paste%3CTab%3ECtrl-V%09%09%3CC-R%3E%2B%0A” message=”bash code” highlight=”” provider=”manual”/]

  • If you want Cut/Copy/Paste to work using the “standard” hotkeys, but you don’t want to change any of the other configuration options in gvim, try do add the following to ~/.vimrc.
[pastacode lang=”bash” manual=”vmap%20%3CC-c%3E%20%22%2Byi%0Avmap%20%3CC-x%3E%20%22%2Bc%0Avmap%20%3CC-v%3E%20c%3CESC%3E%22%2Bp%0Aimap%20%3CC-v%3E%20%3CC-r%3E%3CC-o%3E%2B%0A%0A” message=”bash code” highlight=”” provider=”manual”/] [ad type=”banner”]
  • Paste only works in Visual and insert mode, so you don’t have to worry about the conflict with Ctrl-V and blockwise Visual Mode.
  • This isn’t a problem, because Copy and Cut put you into insert mode, so you can immediately paste afterwards. If you try it out you’ll find that it feels completely natural.

gVim

  • If you use gVim, you can get copy-on-select behaviour when using :set guioptions+=a.
  • This is enabled by default on X11 systems (copies to PRIMARY), but not on MS Windows & OSX (as selecting any text would override your clipboard).

No +clipboard

  • Vim requires the +clipboard feature flag for any of this to work; you can check if your Vim has this by using :echo has(‘clipboard’) from within Vim (if the output is 0, it not present, if it’s 1, it is), or checking the output of vim –version.

Most Linux distributions ship with a “minimal” Vim build by default, which doesn’t have +clipboard, but you can usually install it:

  • Debian & Ubuntu: Install vim-gtk or vim-gnome.
  • Fedora: install vim-X11, and run vimx instead of vim (more info).
  • Arch Linux: install gvim (this will enable +clipboard for normal vim as well).

You could also use xclip, xcopy, or xsel to copy text to the clipboard.

Categorized in: