0

I know that sounds vague. Basically I just want Sublime to highlight custom syntax (color the text), just like it does with native syntax.

I am using Sublime to write LaTeX code. For those that don't know, LaTeX equations are typically enclosed by \[ \], e.g.

\[ E = m c^2 \]

Sublime understands that syntax and colors the enclosing code appropriately.

However, I use my custom defined command, \eq{ ... }, which wraps the \[ \] functionality (so I can globally change some settings by just redefining the \eq definition). e.g.

\eq{ E = m c^2 }

I don't know anything about Sublime under the hood beyond basic key bindings. I want to expand Sublime's understanding of syntax to incorporate my custom command without wasting a ton of time digging through tutorials and such.

1 Answer 1

1

Since you are mainly interested in the result and not in the reasoning, I will try to be as straight forward as I can.

The LaTeX syntax of Sublime Text will change in release 3119 and I would recommend to use that, if you want to change something. Just download it from https://github.com/sublimehq/Packages and put the LaTeX folder into the folder, which opens when you select Preferences >> Browse Packages... in the Sublime Text menu. Afterwards open the file LaTeX.sublime-syntax and search for ensuremath (LaTeX.sublime-syntax#L498). Duplicate that part (everything with a higher indent) and change the command to the command you wish, e.g. in your example this would be - match: '((\\)eq)(\{)'.

Aside the new syntax removes the highlighting of math environments as strings, because this has lead to several problems. I made a small entry in the LaTeXTools wiki to explain, how you restore the highlight.

1
  • Thank you! I didn't mean to come across as anti-intellectual or lazy. I have a tendency to fall down rabbit holes when tweaking customizations and systems. By learning as little as possible here, I'm minimizing that chance Commented Aug 15, 2016 at 17:00

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