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; 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. 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.?
Newer versions of vim allow a
:set numberwidth=x
value, which sets the width of the line number display. I don't really use folding etc, so I wouldn't know about that though. Drawing a thin vertical line is beyond the abilities of a console application though. GVim may allow this (I don't use it, so can't comment there).I have this set up in my .vimrc:
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).
I prefer:
I'm afraid that you've put constraints on the set of solutions that, well, leave you with the null set.
Using
:set textwidth=80
will fix all of the problems you mentioned except that you can't easily see the line limit coming up. If you:set ruler
, you'll enable the x,y position display on the status bar, which you can use to see which column you're in.Aside from that, I'm not sure what to tell you. It's a shame to lose the number column, fold column and splits just because you have to
:set columns=80
.You can try this:
That will set up two highlights in every buffer, one for characters in the 8 columns prior to whatever your
&textwidth
is set to, and one for characters beyond that column. That way you have some extent of anticipation. Of course you can tweak it to use a different width if you want more or less anticipation (which you pay for in the form of loss of syntax highlighting in those columns).Well, looking at the :help columns, it's not really being made to mess with.
In console, it's usually determined by console setting (i.e. it's detected automatically) ; in GUI, it determines (and is determined by) the width of the gvim windows.
So normally you just let consoles and window managers doing their jobs by commented out the
set columns
I am not sure what you mean by "see and anticipate line overflow". If you want EOL to be inserted roughly column 80, use either
set textwidth
orset wrapmargin
; if you just want soft wrap (i.e. line is wrapped, but no actual EOL), then play withset linebreak
andset showbreak
.