Proposed tip Please edit this page to improve it, or add your comments below (do not use the discussion page).
created April 29, 2008 · complexity basic · author Benshi · version 7.0
This tip was tested under Debian with Vim 7.1 (console version).
To easily swap between different registers it is convenient to map a key to move the registers in a "circular list". The following mapping illustrates the idea:
map s :let @x=@" \| let @"=@a \| let @a=@b \| let @b=@x <Return>
Now you can cycle between the registers "", "a, "b by pressing s.
- :let @a=@b copies register "b to register "a.
- | separates Ex commands; \ escapes the pipe for the map command.
This is also useful if you want to copy between the xclipboard and the unnamed standard register of Vim:
map s :let @a=@" \| let @"=@+ \| let @+=@a <Return>
To see what it's changing, you could modify the command like this:
map s :let @x=@" \| let @"=@a \| let @a=@b \| let @b=@x \| reg "ab <Return>
References
Comments
TO DO
- It would be nice to start the tip by describing what we're trying to achieve.
- Perhaps replace <Return> with the <CR> which most other tips use.