So let's review some movement commands in VIM.
hjklfor left up down right
wbefor jumping between words in a sentence.
Now let's say you have a huge paragraph you're jumping through. The whole thing is on one line, but it's like 200 words long. You want to edit word number 155, but you don't necessarily know it's word #155, you just know it's pretty far along in the paragraph.
How do you get there?
Well, if you're like me, you'll probably start hammering on
w, jumping word by word. But then you'll realize "damn, this is going to take a long time" (155 presses, but you're not aware of that).
What's next? Well, you can jump by 10 words, by typing
10w. And you can repeat that by typing
10w10w10w10w10w10w but that also takes a really long time.
So what's the solution?
Macros can be named with any single letter. So first, let's pick a macro name. We'll choose
- Start recording the macro by typing
q, then the macro name
- Type your macro
- End the recording by typing
For the case we just had, where we want to repeat
10w, we would type
Then, to use the macro, we type
And finally, the best part, we can type
@@ to repeat the previous macro.
Of course, this can be used for any action you want to repeat.
Hopefully this tip was helpful. Follow me on here or on twitter for more quick tips as they come up.
Throughout the last year, I have worked part-time as a working student and also studied at the university. I was not the first and not the last one who has combined that during their studies, but the problem for me was, that at the end of the day I have felt absolutely exhausted mentally and physically. That caused problems with my health and motivation to continue working on my goals or anything. (yeah, “goals,” I wish I had something more specific at that time).