Using Registers with the Substitution command
Lately, I have found myself using more than the system clipboard for registers.
Specifically for substitutions, I will use this mapping:
register s will be my source
Then I just enter the substitution command and placing the contents of register s in the source section and the contents of register t in the target section.
The "trick" is to press [Ctrl-R] when you are ready to paste the value of a register in the :s ex command. You will see a double quote, ", as follows:
Now, just enter the desired register, e.g. s for the source, s. Also, just enter the desired register, e.g. t for the target:
Now, just enter the desired register, e.g. s for the source, s. Also, just enter the desired register, e.g. t for the target:
In this particular scenario, I have a specific (perhaps rote), substitution going on and there is no real need for a regular expression in the pattern section (aka in this context, the source).
Certainly we could use various tools to facilitate an accurate, intentional substitution (e.g. anchors). I am not trying to demonstrate these features today.
Vim has plenty of registers (kind of like marks) and it just takes some creativity to leverage this feature to improve your productivity.
Certainly we could use various tools to facilitate an accurate, intentional substitution (e.g. anchors). I am not trying to demonstrate these features today.
Vim has plenty of registers (kind of like marks) and it just takes some creativity to leverage this feature to improve your productivity.




Comments
Post a Comment