Comment on page
Chapter 7: Vim Macros
Macros are a more advanced topic in Vim (and any other editor). If you've mastered the previous chapters, you're already a Vim master. So, let's take it to the next level.
16ggJump to the start line where you're ready to start processing, follow the instructions, see the effect first and then explain.
var myArray = [
Press qa to start recording the macro, and then press I<single quote><Esc>A<single quote><comma><Esc>jq7@a
OMG! What happened, did you get a cold sweat? The results of the previous two block operations were completed in an instant, and finally a little finishing work, remove the comma at the end of the last line, indent the collective, done!
Next, let's explain the operation just now:
qis to start recording the macro,
ais to give the macro recording process a storage location, which can be 0-9 or a-z;
I<single quote><Esc>A<single quote><comma><Esc>jis the operation process of the entire macro you recorded this time, which means inserting a single quote at the beginning of the line, inserting a single quote and a comma at the end of the line, and jumping to the next line;
qnext ends this macro recording;
@is to call up the macro,
ais the name (storage location) of the macro to be called up, and the
7in front of it should be clear, that is, to execute 7 times.
@@calls up the last macro executed again.
All the frequently used and not so frequently used in these seven chapters should have been covered. If you encounter any problems in Vim, or if you miss any regular operations in the tutorial, please feel free to raise them in issues, and I will do my best to answer them or improve them in the tutorial.
Thanks again for your interest! If you love, please share. Love life, love VIM!