I've started with programming in expl3 and vim doesn't realise that underscores are now part of LaTeX identifiers.

I'd be much obliged if somebody could explain how to best configure vim so it has the "usual" word boundaries, including underscores, and also does syntax highlighting of words properly.

I know it should be possible to find this information in the vim documentation, but I prefer a quick-and-dirty solution.

  • 1
    Very interesting question! :) It would be nice to have a LaTeX3 capable editor. Commented Feb 16, 2012 at 9:54
  • Future comment: worth noting that the vimtex plugin has support for expl3 syntax highlighting now (although with my Egyptian bracket convention it does not indent too well)
    – user202729
    Commented Jan 2, 2023 at 0:45

1 Answer 1


Quick and dirty solution

:syn match texStatement "\\[a-zA-Z_:]\+"

or add @

:syn match texStatement "\\[a-zA-Z_:@]\+"

It isn't enough, but looks much better.

But better

Modify $VIM/syntax/tex.vim, search b:tex_stylish, and modify all expressions about it.

  • Fantastic answer! :) Commented Feb 16, 2012 at 9:55
  • @MarcvanDongen: Well, the location of tex.vim is quite different between various platforms. e.g. ~/.vim/vimfiles/syntax.
    – Leo Liu
    Commented Feb 16, 2012 at 13:25
  • @MarcvanDongen :help vimfiles
    – Leo Liu
    Commented Feb 16, 2012 at 14:13
  • @LeoLiu Thanks. I've just started reinstalling vim. Looks promising already. I'm now in the process of changing the LaTeX keywords.
    – user10274
    Commented Feb 16, 2012 at 14:17
  • @LeoLiu Finally managed to make it work. Thanks for your help.
    – user10274
    Commented Feb 16, 2012 at 16:11

You must log in to answer this question.