How to make a continuous vertical line in vim?

I want to make a table in vim.

Making a horizontal line is easy


For the vertical I use this

yes "|" | head -10

But the result is bad


I want something contiguous like the horizontal line. How can I do this?

Asked By: elbarna


If your version of Vim is compiled with multibyte support and your terminal encoding is set correctly, you may use the Unicode box-drawing characters, which include horizontal and vertical lines as well as several varieties of intersections and blocks. Vim defines some default digraphs for these characters, such as vv for (to enter a digraph, you use CtrlK; thus in insert mode ^Kvv will insert the character at the cursor location). For the full list if your version of Vim supports it, type :digraphs; for more information on the feature and to search by Unicode character name, type :help digraphs.

Depending on your terminal settings and choice of font, however, box-drawing characters may not all render as connected lines, so your mileage may vary. For instance, on my machine vertical lines render as connected in the terminal (using Source Code Pro), but as broken lines in GVim (using DejaVu Sans Mono):

Box-drawing characters rendering as solid lines in the terminal
Box-drawing characters rendered as broken lines in GVim

Answered By: trent

For completeness, regarding the previous answer:

  • ^kvv leads to │
  • ^kdr leads to ┌
  • ^khh leads to ─
  • ^kdl leads to ┐
  • ^kur leads to └
  • ^kul leads to ┘

Notice you can use upper case for a thicker line:

  • ^kVV is ┃
  • ^kDR is ┏
  • ^kHH is ━
  • ^kLD is ┓ (LD, and not DL, for some reason)
  • ^kUR is ┗
  • ^kUL is ┛

There are also versions with one upper and one lower case.

Answered By: Ricardo Kullock
Categories: Answers Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.