I use vimtex plugin for writing tex documents in vim8. I added custom hilight for sections in my .vimrc like so:

autocmd FileType tex :syntax match texSectioning "\\section.*"

The texSectioning is defined in my color scheme file in .vim/colors.

It works on any file with .tex extension except for one! Copying/movig the file to different dir or/and changing name, changing file extention to .txt and then manually switching on tex filetype does not help. Even typing

syntax match texSectioning "\\section.*"

command has no effect. There is no .swp file, I didn't use mkview (there is no view folder in .vim), I didn't use sessions.

I'm really confused by this...


the output of set filetype is filetype=tex. The standard syntax highlighting works, I'm only missing he custom one.

Apparently, removing .latexmkrc solved the problem. There must have been some interference between vimtex and latexmk, but it is wierd if that was the case...

  • 1
    Check the output of set filetype in that file. If it is 'plaintex', then you should add let g:tex_flavor = 'latex' in your vimrc file. Jan 28 '19 at 12:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.