Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

The way I do 80-column indication in Vim seems incorrect:set columns=80. At times I also set textwidth, but I want to be able to see and anticipate line overflow with the set columns alternative.

This has some unfortunate side effects:

  1. I can't set number for fear of splitting between files that have different orders of line numbers; i.e. < 100 line files and >= 100 line files will require two different set columns values because of the extra column used for the additional digit display.
  2. I also start new (g)Vim sessions instead of splitting windows vertically. This is because vsplit forces me to set columns every time I open or close a pane, so starting a new session is less hassle.

How do you handle the 80-character indication when you want to set numbers, vertically split, etc.?

Question&Answers:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
635 views
Welcome To Ask or Share your Answers For Others

1 Answer

As of vim 7.3, you can use set colorcolumn=80 (set cc=80 for short).

Since earlier versions do not support this, my .vimrc uses instead:

if exists('+colorcolumn')
  set colorcolumn=80
else
  au BufWinEnter * let w:m2=matchadd('ErrorMsg', '\%>80v.+', -1)
endif

See also the online documentation on the colorcolumn option.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...