Vim Tips Wiki
Register
Advertisement

This tip was tested under Debian testing with Vim 7.1 (console version)

To easily swap between different registers in Vim it is convenient to map a sequence to move all in a "circled list". See the following mapping to understand it:

map s :let @x=@" \| let @"=@a \| let @a=@b \| let @b=@x <Return>


Now you can circle between the registers "", "a, "b with s.

(:let @a=@b copies register "b to register "a; | concaternates ex commands - \ is used to escape the pipe in your vimrc)


This is also usefull if you want to copy between xclipboard and the unnamed standard register of Vim:

map s :let @a=@" \| let @"=@+ \| let @+=@a <Return>


To see, what ist changing, you could modify the command above like this:

map s :let @x=@" \| let @"=@a \| let @a=@b \| let @b=@x \| reg "ab <Return>


For further Information see:

:help let
:help reg
:help registers


--Benshi 11:18, 29 April 2008 (UTC)

Advertisement