How to fill a line with character x up to column y using Vim

前端 未结 9 640
野的像风
野的像风 2020-12-23 18:17

How can I fill the remainder of a line with the specified character up to a certain column using Vim? For example, imagine that the cursor is on column four and I want to fi

9条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-23 18:22

    If I understand the question correctly, this can be accomplished like this: in normal mode subtract the cursor's current column position from the desired ending column, then type the result followed by 'i' to enter insert mode, then the character you want to fill the space with. End by returning to normal mode. For example, with the cursor at column four in normal mode, if you wanted to fill the rest of the line up to column 80 with dashes, type 76i- then Esc or Ctrl-[ to return to normal mode. This should result in 76 dashes starting in column 4 and ending in column 79.

提交回复
热议问题