TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
Very interesting question! :) It would be nice to have a LaTeX3 capable editor. – Paulo Cereda Feb 16 '12 at 9:54
up vote 11 down vote accepted

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.

share|improve this answer
Fantastic answer! :) – Paulo Cereda Feb 16 '12 at 9:55
@MarcvanDongen: Well, the location of tex.vim is quite different between various platforms. e.g. ~/.vim/vimfiles/syntax. – Leo Liu Feb 16 '12 at 13:25
@MarcvanDongen :help vimfiles – Leo Liu Feb 16 '12 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. – Marc van Dongen Feb 16 '12 at 14:17
@LeoLiu Finally managed to make it work. Thanks for your help. – Marc van Dongen Feb 16 '12 at 16:11

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.