I use and love the plugin calendar.vim. Those days, I decided to add the following to my vimrc
:
autocmd BufEnter *.tex,*.md call matchdelete(4)
autocmd BufLeave *.tex,*.md call matchadd("ErrorMsg", "\\%>80v.\\+", 10, 4)
This way, if I alternate to a buffer that contains a .tex
or a .md
file, the error after 80chars becomes disabled. If I alternate to a buffer with any other type of file, it's enabled again. The problem is, it makes most of the calendar buffer become marked with error highlighting. Simply adding calendar
as file extension in the above code does not work.
Searching through the issues of the plugin's github, I found the following issue raised: https://github.com/itchyny/calendar.vim/issues/98. There, the plugin's author give a code snippet for making it so that the above type of error message for long lines does not display over the calendar:
autocmd BufEnter,FileType *
\ if &l:filetype ==# 'calendar'
\ | match
\ | else
\ | match ErrorMsg '\%>80v.\+'
\ | endif
But with only that, I loose the ability of also having the error highlighting disabled with tex
and md
files. I tried the following:
autocmd BufEnter,FileType *
\ if &l:filetype ==# 'calendar' || &l:filetype ==# 'tex' || &l:filetype ==# 'md'
\ | match
\ | else
\ | match ErrorMsg '\%>80v.\+'
\ | endif
However, that also does not work well. It disables the error highilghting only on the calendar buffer, not on buffers displaying tex or md files.
Then, my question. Is there a way I can have the above code modified such that I could have the error highlighting for over 80chars lines when I navigate my cursor to buffers containing any other files than tex, md or the buffer calendar?