Vim Tips Wiki
Register
m (Reverted edits by Emprego.curitiba (talk | block) to last version by 213.85.69.114)
(Change <tt> to <code>, perhaps also minor tweak.)
Line 5: Line 5:
 
|previous=20
 
|previous=20
 
|next=22
 
|next=22
|created=February 25, 2001
+
|created=2001
 
|complexity=basic
 
|complexity=basic
 
|author=jean
 
|author=jean
Line 51: Line 51:
 
On Windows, the clipboard is both "* and "+. On X11 they are different, but the one used for Edit=>Cut, Edit=>Copy and Edit=>Paste (both in gvim and in non-Vim applications) is actually the + register. — [[User:Tonymec|Tonymec]] 11:09, March 24, 2010 (UTC)
 
On Windows, the clipboard is both "* and "+. On X11 they are different, but the one used for Edit=>Cut, Edit=>Copy and Edit=>Paste (both in gvim and in non-Vim applications) is actually the + register. — [[User:Tonymec|Tonymec]] 11:09, March 24, 2010 (UTC)
   
: True, under X11, + is the clipboard register, while * is selection register. Newer vim versions (7.3.74 and higher) finally have a variation of clipboard=unnamed option which allows you to alias unnamed register to the + register: <tt>set clipboard=unnamedplus</tt>. Enjoy! -- [[Special:Contributions/213.85.69.114|213.85.69.114]] 21:23, January 17, 2011 (UTC)
+
: True, under X11, + is the clipboard register, while * is selection register. Newer vim versions (7.3.74 and higher) finally have a variation of clipboard=unnamed option which allows you to alias unnamed register to the + register: <code>set clipboard=unnamedplus</code>. Enjoy! -- [[Special:Contributions/213.85.69.114|213.85.69.114]] 21:23, January 17, 2011 (UTC)

Revision as of 05:07, 13 July 2012

Duplicate tip

This tip is very similar to the following:

These tips need to be merged – see the merge guidelines.

Tip 21 Printable Monobook Previous Next

created 2001 · complexity basic · author jean · version 5.7


In Vim, the unnamed register is the " register, and the Windows Clipboard is the * register.

This means that if you yank something, you have to yank it to the * register if you want to paste it into a Windows app. If this is too much trouble, set the 'clipboard' option to 'unnamed'. Then you always yank to *.

So pasting to windows apps doesn't require prefixing "* :

set clipboard=unnamed

Comments

You can also have the Visual selection automatically copied to the clipboard. If you

:set go+=a

and then make a Visual selection, you can switch to another application (such as your mail reader) and paste.


Since the * buffer won't allow (as far as I know anyway) appending to it, you also do something like:

"aY

to grab a line then move somewhere else

"AY

to append another line to the a buffer. Then:

:let @*=@a

This puts both lines into the * buffer for pasting.


This tip, set clipboard=unnamed, also works under the X windowing system.

BenArmston 09:52, 23 May 2008 (UTC)

Well, if you still have a good ol' 3-button mice and paste by middle-clicking, yeah it works. But keyboard shortcuts for clipboard operations in modern GUI apps (Ctrl-C, Ctrl-V, etc) - they don't play along with clipboard=unnamed. -- 213.85.69.114 21:30, January 17, 2011 (UTC)

On Windows, the clipboard is both "* and "+. On X11 they are different, but the one used for Edit=>Cut, Edit=>Copy and Edit=>Paste (both in gvim and in non-Vim applications) is actually the + register. — Tonymec 11:09, March 24, 2010 (UTC)

True, under X11, + is the clipboard register, while * is selection register. Newer vim versions (7.3.74 and higher) finally have a variation of clipboard=unnamed option which allows you to alias unnamed register to the + register: set clipboard=unnamedplus. Enjoy! -- 213.85.69.114 21:23, January 17, 2011 (UTC)