Vim: insert the same characters across multiple lines

后端 未结 12 1917
慢半拍i
慢半拍i 2020-11-29 14:23

Sometimes I want to edit a certain visual block of text across multiple lines.

For example, I would take a text that looks like this:

name
comment
ph         


        
12条回答
  •  半阙折子戏
    2020-11-29 15:00

    I would use a macro to record my actions and would then repeat it.

    1. Put your cursor on the first letter in name.
    2. Hit qq to start recording into the q buffer.
    3. Hit i to go into insert mode, type vector_, and then hit Esc to leave insert mode.
    4. Now hit 0 to go back to the beginning of the line.
    5. Now hit j to go down.
    6. Now hit q again to stop recording.

    You now have a nice macro.

    Type 3@q to execute your macro three times to do the rest of the lines.

提交回复
热议问题