In vim I am trying to have it highlight my screen when it goes over 80 characters (I am a kernel developer and this is a requirement for kernel code). I am using the following in my .vimrc file to do this
highlight OverLength ctermbg=red ctermfg=white guibg=#59292
match OverLength /\%81v.\+/
which was suggested here: Vim 80 column layout concerns
However, I am colorblind and as a result I cannot use the default colorscheme and see the text on the screen so I change my default colorscheme using :colorscheme torte
as well. However, it appears that the colorscheme overrides the highlighting on me (it highlights fine when I don't have the colorscheme specified, and doesn't when it is specified).
Does anyone have any ideas on how to make this work with the colorscheme
change? Thanks for your help,
Show activity on this post. There are several reasons to still adhere to an 80 character limit (or, a 74 character limit is even better; it allows for the code to remain fewer than 80 columns even when diff markers and email quoting is added, if you do code review on mailing lists).
And with 96 characters per line code can be made much more readable than with 80. I don't buy the argument that most people set their terminals to 80 characters wide, no that printers have to wrap lines longer than 80 characters. It's not a hard limit as it used to be in the (distant) past.
You asked for the best practice, and the best practice is "focus on making the code as readable as possible". If that requires more than 80 characters, so be it. Show activity on this post.
80 characters is still relevant because many people default to having their terminals and editors that wide; thus, if you limit yourself to 80, you will be friendly towards those folks, as opposed to requiring them to rearrange all of their windows or deal with line wrapping or horizontal scrolling.
If you have Vim 7.3+ you can use:
:set colorcolumn=81
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With