How to draw a line in VIM?

How to draw a vertical line instead of typing one at a time?

For example, I want to set a vertical line in column 10 for 20 rows. Like my first line. How can I do this in a smart way?

enter image description here

+6
source share
3 answers

First set virtualedit=all to allow you to move around the end of the line:

 :set virtualedit=all 

Then...

 10|<CV>20jr| 

Where:

  • 10| : moves you to screen column 10
  • ctrl + V : introduces a phased visual mode
  • 20j : you move 20 lines (adapt to taste)
  • r| : replaces stripe highlighting
+12
source

Below is an alternative solution for setting virtualedit=all to make 20 lines with | in column 10:

  • Starting with Normal , enter an example string, for example. 10i<space><esc>r|
    • 10i space will insert space ten times, and pressing esc followed by r| will replace the last character with |
  • Copy the whole line with Y
  • In normal mode, paste the copied string 20 times using 20p
    • This will copy the recently copied row 20 times lower, giving you a total of 21 identical rows.

In total:

 10i<space><esc>r|Y20p 
+2
source

This is apparently a VIM plugin that does exactly what you are looking for:

http://www.vim.org/scripts/script.php?script_id=40

I have not tried it myself.

+1
source

Source: https://habr.com/ru/post/902466/


All Articles