No edit summary |
JohnBeckett (talk | contribs) (Add TipProposed + comments + todo (thanks Benshi for the new tip!)) |
||
Line 1: | Line 1: | ||
+ | {{TipProposed |
||
⚫ | |||
+ | |id=0 |
||
+ | |previous=0 |
||
+ | |next=0 |
||
+ | |created=April 29, 2008 |
||
+ | |complexity=basic |
||
+ | |author=[[User:Benshi|Benshi]] |
||
+ | |version=7.0 |
||
+ | |subpage=/200804 |
||
+ | |category1= |
||
+ | |category2= |
||
+ | }} |
||
⚫ | |||
− | To easily swap between different registers |
+ | 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> |
||
− | + | map s :let @x=@" \| let @"=@a \| let @a=@b \| let @b=@x <Return> |
|
+ | </pre> |
||
+ | Now you can cycle between the registers <tt>""</tt>, <tt>"a</tt>, <tt>"b</tt> by pressing <tt>s</tt>. |
||
+ | *<tt>:let @a=@b</tt> copies register <tt>"b</tt> to register <tt>"a</tt>. |
||
+ | *<tt>|</tt> separates Ex commands; <tt>\</tt> 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> |
||
⚫ | |||
+ | </pre> |
||
⚫ | |||
− | ('':let @a=@b'' copies register "b to register "a; | concaternates ex commands - \ is used to escape the pipe in your vimrc) |
||
+ | <pre> |
||
⚫ | |||
+ | </pre> |
||
+ | ==References== |
||
+ | *{{help|:let}} |
||
+ | *{{help|:reg}} |
||
+ | *{{help|:reg}} |
||
+ | *{{help|map_bar}} |
||
+ | ==Comments== |
||
− | This is also usefull if you want to copy between xclipboard and the unnamed standard register of Vim: |
||
+ | {{Todo}} |
||
⚫ | |||
+ | *It would be nice to start the tip by describing what we're trying to achieve. |
||
− | |||
+ | *Perhaps replace <tt><Return></tt> with the <tt><CR></tt> which most other tips use. |
||
− | |||
⚫ | |||
⚫ | |||
− | |||
− | |||
− | For further Information see: |
||
− | <pre>:help let |
||
− | :help reg |
||
− | :help registers</pre> |
||
− | |||
− | |||
− | --[[User:Benshi|Benshi]] 11:18, 29 April 2008 (UTC) |
Revision as of 23:23, 29 April 2008
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.