Last Updated: February 25, 2016
·
1.247K
· supersymmetry

Vim text width and the console: 80 columns

I like to focus on proper coding practices and expressing the philosophy of the FOSS community. As part of this practice, I leave my code in such a state that it remains readable in many circumstances. Of course I do not obfuscate my code and I always try to leave useful comments but there is more you can do to help out the people who may follow up on your work. One way is to ensure that your code does not exceed the width of 80 columns, as much - if not all - consoles work on a 80x24 basis. This little tip can help out with keeping track in vim:

augroup vimrc_autocmds
  autocmd BufEnter * highlight OverLength 
                \ ctermbg=darkgrey guibg=#592929
  autocmd BufEnter * match OverLength /\%74v.*/
augroup END

This snippet will highlight any text that surpasses the given value, in this case it's being set at 74 but you may tweak this to your own likings just as with any colors obviously.

Thanks a lot to Edward Z. Yang for his excellent blog post on this subject, read it if you like to learn more!