I've been doing quite a bit of file editing at the command line recently. Rather than using the my good old standby editor pico, I've been forcing myself to use vim for the last 6 months. After doing a bunch of command line editing recently I think it's finally paid off. Plus, I recently discovered a new trick!
Those of you who may be familiar with this little program know a search and replace can be conducted using the following command :
%s/thing to find/thing to replace/g
Usually when I do this there's something in my editing buffer I want to search for and replace so I dutifully retype what I want to search for and replace and hit enter. Then realize oops typo, and have to hit u to undo and repeat the process.
Now I've finally learned how to paste into the command buffer. Simply start your command, then when you want to paste type ctrl-r then hit " to paste the last thing you yanked. Even better you can paste from any of the numbered or named vi registers. For example you can yank something into the a" register by typing a"y rather than just hitting y. Now when you use ctrl-r hit a and bam your thing in a gets pasted into place.
You can combine this with any of the 26 a-z registers to juggle up to 26 things at once! BTW, to paste normally from the special registers you just type x"p where x is your register name (a in previous example).
The only downside of my newfound vim skills is that I now find myself typing :w in Word to try and save my work.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment