So I found this solution on StackOverflow here: Vim 80 column layout concerns
If I type a long line in my file, I would like the characters that exceed a limit of 80 characters to be highlighted. A lot of people seem to think that this solution works fine, but I have it in my vimrc file and it behaves as though nothing has changed at all. My long lines do not get highlighted.
highlight OverLength ctermbg=red ctermfg=white guibg=#592929
match OverLength /\%81v.\+/
For reference, here is my entire .vimrc, which isn’t that long:
" You'll need to add the following to your ~/.vimrc so that pathogen will be loaded
" properly. Filetype detection must be off when you run the commands so its best to
" You'll need to add the following to your ~/.vimrc so that pathogen will be loaded
" execute them first:
"filetype off
call pathogen#runtime_append_all_bundles()
call pathogen#helptags()
"filetype on
syntax on
let mapleader = ","
let g:CommandTMaxHeight=25
imap ii <Esc>
map <S-Enter> O<Esc>
map <CR> o<Esc>
set guioptions-=T
set guioptions-=r
set hlsearch
highlight OverLength ctermbg=red ctermfg=white guibg=#592929
match OverLength /\%79v.\+/
set nocompatible
set ruler
set number
set shellcmdflag=-ic
set list
set expandtab
set tabstop=4
set softtabstop=4
nmap <C-k> ddkP
nmap <C-j> ddp
vmap <C-k> xkP`[V`]
vmap <C-j> xp`[V`]
au! BufWritePost vimrc source %
colorscheme vividchalk
From: https://stackoverflow.com/a/10993757/1701170
This works for me whereas the solution I had before does not. I’m not exactly sure why, but another commenter on the page offers a hint when he remarks, regarding the solution without opening and closing
augrouplines, “This only works for the first file you open in any given buffer”.Now if someone could explain why the additional opening and closing lines solve that first-file-in-any-given-buffer problem, and why that problem exists in the first place, then I would feel enlightened.