To my biggest surprise, the multi-line comment syntax in TeX :
\usepackage{verbatim}
...
\begin{comment}
I don't like this line anymore. Please don't print it.
\end{comment}
is not recognized/dealt with by $VIMRUNTIME/syntax/tex.vim
and hence not colored as a comment. Is there a VIM scripting Guru that could have a solution around, as I'm sure a lot of people have been looking for it ?
Thanks
VIM v7.3
A little search on VIM Syntax highlighting helped me write this line of code who does almost the whole work when added to ~/.vim/after/syntax/tex.vim
(you may need to create the directory in your ~/.vim
directory):
syn region texComment start="\\begin{comment}" end="\\end{comment}"
My only problem is that it can't find how to disable the matching if it encounters end-of-file before end of comment environment. Anyone has a work-around ?
NB : This command does not support nesting, which is a good thing since Latex neither and you will most likely have unmatched \end{comment}
There are more options how to comment code (see multiline comment), so this is content of mine ~/.vim/after/syntax/tex.vim
:
syn region texComment start="\\begin{comment}" end="\\end{comment}"
syn region texComment start="\\iffalse" end="\\fi"
syn region texComment start="\\ifx true false" end="\\fi"
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