Vim Tips Wiki
Explore
Main Page
All Pages
Community
Interactive Maps
Community portal
To do
FANDOM
Fan Central
BETA
Games
Anime
Movies
TV
Video
Wikis
Explore Wikis
Community Central
Start a Wiki
Don't have an account?
Register
Sign In
FANDOM
Explore
Current Wiki
Start a Wiki
Don't have an account?
Register
Sign In
Sign In
Register
Vim Tips Wiki
1,649
pages
Explore
Main Page
All Pages
Community
Interactive Maps
Community portal
To do
Editing
Comfortable handling of registers
Back to page
Edit
Edit source
View history
Talk (0)
Edit Page
Comfortable handling of registers
We recommend that you
log in
before editing. This will allow other users to leave you a message about your edit, and will let you track edits via your
Watchlist
.
Creating an account
is quick and free.
The edit appears to have already been undone.
Anti-spam check. Do
not
fill this in!
{{TipNew |id=1562 |previous=1561 |next=1563 |created=2008 |complexity=basic |author=[[User:Benshi|Benshi]] |version=7.0 |subpage=/200804 |category1=Registers |category2= }} This tip explains how to cycle between several registers, while accessing their content through the standard "unnamed" register (<code>@"</code>). 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: <pre> :nnoremap <Leader>s :let @x=@" \| let @"=@a \| let @a=@b \| let @b=@x<CR> </pre> Now you can cycle between the registers <code>""</code>, <code>"a</code>, <code>"b</code> by pressing <code>\s</code> (assuming the default backslash for the leader key). *<code>:let @a=@b</code> copies register <code>"b</code> to register <code>"a</code>. *<code>|</code> separates Ex commands; <code>\</code> 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: <pre> :nnoremap <Leader>s :let @a=@" \| let @"=@+ \| let @+=@a<CR> </pre> Another usage can be found in cycling through the cut/copy history, i.e. cycling through the numbered registers. To see what it's changing, you could modify the command like this: <pre> :nnoremap <Leader>s :let @x=@" \| let @"=@a \| let @a=@b \| let @b=@x \| reg "ab<CR> </pre> ==References== *{{help|:let}} *{{help|:reg}} *{{help|registers}} *{{help|map_bar}} ==Comments==
Summary:
Please note that all contributions to the Vim Tips Wiki are considered to be released under the CC-BY-SA
Cancel
Editing help
(opens in new window)
Templates used on this page:
Template:Help
(
view source
)
Template:Navigation
(
view source
)
Template:TipNew
(
view source
)
Follow on IG
TikTok
Join Fan Lab