Today I had to do something like moving a text following a pattern to a next line.
Eg: sometext; othertext
I didn’t wanted to go through all the lines individually and move it
to next line. At that time, I heard something called as “recording”
from one of my friends. As per that I did the following and I felt in
very deeeeeeeeeeeeeeeeeep love with VIM.
- Entered recording mode by pressing “q” followed by a letter say “a”
- Then searched for “;” using “/” and then went to insert mode
- Inserted a new line and then moved down to next line.
- Pressed “q” again to quit recording mode.
- Then pressed “@a” and it replaced the first occurance of the pattern to next line.
- To repeat 10 times, I used “10@a”
Once we are in recording mode, vim stores all the key strokes with the name we give. Then replays all the actions when we use “@”. Similar to “play” in a tape recorder.
The number (10) indicates the number of times to replay.
Really a nice feature of VIM…