JohnBeckett (talk | contribs) (Change maps to use nnoremap and leader) |
(Assign tip id + convert to TipNew template + minor clean) |
||
Line 1: | Line 1: | ||
+ | {{TipNew |
||
− | {{TipProposed |
||
− | |id= |
+ | |id=1562 |
− | |previous= |
+ | |previous=1561 |
− | |next= |
+ | |next=1563 |
|created=April 29, 2008 |
|created=April 29, 2008 |
||
|complexity=basic |
|complexity=basic |
||
Line 15: | Line 15: | ||
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: |
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> |
<pre> |
||
− | :nnoremap <Leader>s :let @x=@" \| let @"=@a \| let @a=@b \| let @b=@x |
+ | :nnoremap <Leader>s :let @x=@" \| let @"=@a \| let @a=@b \| let @b=@x<CR> |
</pre> |
</pre> |
||
Line 24: | Line 24: | ||
This is also useful if you want to copy between the xclipboard and the unnamed standard register of Vim: |
This is also useful if you want to copy between the xclipboard and the unnamed standard register of Vim: |
||
<pre> |
<pre> |
||
− | :nnoremap <Leader>s :let @a=@" \| let @"=@+ \| let @+=@a |
+ | :nnoremap <Leader>s :let @a=@" \| let @"=@+ \| let @+=@a<CR> |
</pre> |
</pre> |
||
Line 31: | Line 31: | ||
To see what it's changing, you could modify the command like this: |
To see what it's changing, you could modify the command like this: |
||
<pre> |
<pre> |
||
− | :nnoremap <Leader>s :let @x=@" \| let @"=@a \| let @a=@b \| let @b=@x \| reg "ab |
+ | :nnoremap <Leader>s :let @x=@" \| let @"=@a \| let @a=@b \| let @b=@x \| reg "ab<CR> |
</pre> |
</pre> |
||
Revision as of 04:48, 12 May 2008
created April 29, 2008 · complexity basic · author Benshi · version 7.0
This tip explains how to cycle between several registers, while accessing their content through the standard "unnamed" register (@").
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:
:nnoremap <Leader>s :let @x=@" \| let @"=@a \| let @a=@b \| let @b=@x<CR>
Now you can cycle between the registers "", "a, "b by pressing \s (assuming the default backslash for the leader key).
- :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:
:nnoremap <Leader>s :let @a=@" \| let @"=@+ \| let @+=@a<CR>
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:
:nnoremap <Leader>s :let @x=@" \| let @"=@a \| let @a=@b \| let @b=@x \| reg "ab<CR>