(Change to TipImported template + severe manual clean) |
(Move categories to tip template) |
||
Line 9: | Line 9: | ||
|version=5.7 |
|version=5.7 |
||
|rating=-2/17 |
|rating=-2/17 |
||
+ | |category1= |
||
+ | |category2= |
||
}} |
}} |
||
I wish to use selected text as part of a command - say, to substitute instances of a very long variable with a shorter name: |
I wish to use selected text as part of a command - say, to substitute instances of a very long variable with a shorter name: |
Revision as of 01:24, 25 April 2008
Tip 409 Printable Monobook Previous Next
created January 21, 2003 · complexity basic · author Lyle · version 5.7
I wish to use selected text as part of a command - say, to substitute instances of a very long variable with a shorter name:
:%s/<selected text>/ShorterName/g
How do I do that?
Comments
- yank your selected text using the 'y' key.
- when entering your command you can use control-r followed by " whenever you need your selections. (control-r " inserts the contents of the "-register which is the standard register for yanking)
Just put the cursor over the word in your text. In the command line press <C-R><C-W> the to get the word.
See h: c_<C-R>_<C-W>
I have the following maps:
vmap ,g :s/<C-R>// map ,g :s/<C-R>//
I then just add the closing delimiter and flags and hit return. These mappings have saved me a great deal of time.