Some command sequences consisting of \ and a non-letter (,, 2) are not coloured (\& is). How to fix?


Maybe to signal that your macro/command would be invalid?

I'm not saying it's the right way, just what's the idea.

Vim TeX statements (part of the texCmdGroup), from $VIMRUNTIME/syntax/tex.vim:

" TeX/LaTeX keywords: {{{1
" Instead of trying to be All Knowing, I just match \..alphameric..
" Note that *.tex files may not have "@" in their \commands
if exists("g:tex_tex") || b:tex_stylish
  syn match texStatement    "\\[a-zA-Z@]\+"
  syn match texStatement    "\\\a\+"
  if !exists("s:tex_no_error") || !s:tex_no_error
   syn match texError       "\\\a*@[a-zA-Z@]*"

In addition, recognized special chars are:

syn match texSpecialChar    "\\[$&%#{}_]"

You can add a syntax rule for the texStatement in ~/.vim/after/syntax/tex.vim: e.g. syn match texStatement "\\[0-9 ,;\\]".

| improve this answer | |
  • But it would not? \, and \3 are perfectly valid command sequence names. – Toothrot Sep 24 '15 at 20:51
  • Edited with some digging. – VanLaser Sep 24 '15 at 21:21
  • I tried but it didn’t work. I don’t think I have the file you cited. Are you using vim-latex/latex-suite? – Toothrot Sep 24 '15 at 21:43
  • 1
    No, you'l have to create the .../after/syntax/tex.vim file yourself (see for example usevim.com/2012/03/07/syntax-highlighting ) – VanLaser Sep 24 '15 at 21:48
  • Better: syn match texStatement "\\[^a-zA-Z]". – Toothrot Sep 24 '15 at 23:30

Your Answer

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

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