Vim 80 column layout concerns

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

This has some unfortunate side effects -- I can't set number for fear of splitting between files that have different orders of line numbers; ie < 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. I also start new (g)Vim sessions instead of splitting windows vertically, which forces me to use the window manager's clipboard -- vsplit s force me to do 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.?


I have this set up in my .vimrc:

highlight OverLength ctermbg=red ctermfg=white guibg=#592929
match OverLength /%81v.+/

This highlights the background in a subtle red for text that goes over the 80 column limit (subtle in GUI mode, anyway - in terminal mode it's less so).


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.


较短的方法:

match ErrorMsg '%>80v.+'
链接地址: http://www.djcxy.com/p/22576.html

上一篇: 我不能退出Vim,我命中逃跑并尝试:q:x:qx

下一篇: Vim 80列布局担忧