Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

vim: Change default paste register

Tags:

vim

When I yank or delete text in vim, and run :reg, I see that it's going in to register ". But when I paste, I see "E353: Nothing in register: *"

What I get out of this is that vim is yanking to " but pasting from *.

:set clipboard?
\ clipboard=
:echo version
\ 704

Is it possible to change the register that vim attempts to yank from? Or am I asking the wrong question?

EDIT:

To yank, I use yy (or dd or ci' etc).

like image 303
Josh Whittington Avatar asked May 30 '14 02:05

Josh Whittington


1 Answers

You can't change the default register: it will always be the unnamed register, ".

What you can do, though, is synchronize the unnamed register with the clipboard register:

set clipboard^=unnamed

See :help 'clipboard'.

For reference…

Vim's documentation generally advises to add your custom values to the default ones rather than overriding them. You can do that with += to append or ^= to prepend. On Windows or Mac OS X, the default value of clipboard is empty so set clipboard=unnamed could be enough but the default value on Linux doesn't accept anything after its last entry so unnamed must be prepended. set clipboard^=unnamed is a safer, cross-platform, choice:

:set clipboard^=unnamed
:set clipboard?

Linux:    unnamed,autoselect,exclude:cons\|linux
Mac OS X: unnamed
Windows:  unnamed
like image 67
romainl Avatar answered Sep 20 '22 19:09

romainl