Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Highlighting more than 80 characters with a non-standard colorscheme

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,

like image 206
SaxyTimmy Avatar asked Oct 17 '11 17:10

SaxyTimmy


People also ask

Why is there an 80 character limit for code?

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).

Is 96 characters per line code too much?

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.

What is the best practice for making code longer than 80 characters?

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.

Is 8080 characters still relevant in 2019?

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.


1 Answers

If you have Vim 7.3+ you can use:

:set colorcolumn=81
like image 102
Peter Rincker Avatar answered Sep 19 '22 13:09

Peter Rincker