Vim: insert the same characters across multiple lines

后端 未结 12 1924
慢半拍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 14:58

    An alternative that can be more flexible:

    Example: To enter the text XYZ at the beginning of the line

    :%norm IXYZ
    

    What's happening here?

    • % == Execute on every line
    • norm == Execute the following keys in normal mode
    • I == Insert at beginning of line
    • XYZ == The text you want to enter

    Then you hit Enter, and it executes.

    Specific to your request:

    :%norm Ivendor_
    

    You can also choose a particular range:

    :2,4norm Ivendor_
    

    Or execute over a selected visual range:

    :'<,'>norm Ivendor_
    

提交回复
热议问题