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

前端 未结 9 638
野的像风
野的像风 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:23

    If you have the virtualedit option set to block or all, you can create a visual selection (even over empty space) up to the desired column:
    v80| (if virtualedit=all) or
    80| (if virtualedit=block)

    Then replace the selected area with dashes: r-

    It's probably helpful to start visual mode after the last character in the line by hitting l to avoid overwriting the last character in the line. If you are not using virtualedit=all, then you need to set virtualedit+=onemore so you can move one character beyond the end of line in normal mode.

提交回复
热议问题