Vim tips (5) - Recording and using macros

Imagine a scenario, how fast we can put all the links below are in double quotation marks? Maybe you fast hand speed, can quickly add complete, but if there are tens of thousands of links to it? How do you add finished within ten seconds?

 

 

This time you need to use the macro (macro also vim fact, in addition there are other methods you can use other methods in quotes, here is a simple example to illustrate this)

The concept of the macro is like a movie, we have recorded a series of operations to register it, use the time, directly to the operation of (movie) show again. Here, we use the simple example above, step by step look at the power of macros.

1. recording a macro, we need to click q to begin recording the macro (short film), q click again to end recording. a representative of the macro (small movie) name, a ~ z just one letter can be.

qa

After you start recording, there will be the lower left corner

 

2. Enter a series of commands, so that the first link in quotes before and after

^ // move to the first line

  

i // insert

  

"// enter double quotes

  

[ESC] // click esc exit to normal mode

  

A // move to the end of the line and insert mode

  

"// enter double quotation marks again

  

[ESC] // esc click again to exit to normal mode

  

3. Press q, the end of the macro (small movie) recording

 

Guess you like

Origin www.cnblogs.com/shifu204/p/10944436.html