13

I am not using vim-latex, just the regular vim syntax highlighting for latex. To make sure of this I tested this by running:

vim -u NONE -N

I notice that if I am in math mode "f_a" will display with "_a" being the same color as the inside of "f_{a}" but when typing "f_b" the underscore displays red while "b" is the same color as f. I noticed that all numbers behave like a, and also a few other letters, including x, v, u and i. What is special about these letters? Why does the syntax consider them different?

Is there a flavor of TeX where the difference is meaningful? I am only familiar with LaTeX...

3
  • 4
    TeXnical speaking, there is no difference. Commented Sep 28, 2013 at 16:09
  • Depends on what syntax highlighting package you are using (the one that comes with vim, or the one that is part of latex-suite, or a bunch of others that are floating around the net). It is impossible to answer without knowing that.
    – Aditya
    Commented Sep 28, 2013 at 16:14
  • @Aditya see the change in my question
    – vlsd
    Commented Sep 28, 2013 at 16:44

1 Answer 1

12
+50

Recent versions of Vim have a new 'conceal text' function. The syntax highlighting file contains code to work with this feature. The conceal text function collapses a string of text into a single Unicode character. For example, it might visually substitute \beta with β.

Vim provides substitutions for the following subscripts by default, replacing the string _X (where X is one of the following characters) with the Unicode subscript character: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, a, e, i, o, u, , (replaced with a vertical comma: U+FE10), +, -, /, (, ), . (replaced with a caret: U+2038), r, v, x, \beta, \delta, \phi, \gamma, \chi.

The characters that are replaced will appear in a different color (depending on your color scheme and the current conceal mode).

To enable conceal mode, type :set conceallevel=2 in Vim. You'll see these replacements (assuming you have a terminal font that supports the necessary Unicode characters). When your cursor is on a line, the concealed characters are revealed/expanded for easy editing. Use :set conceallevel=0 to disable the concealment.

Vim has many more replacements for superscripts (as more fonts provide a wider variety of superscript glyphs than subscript glyphs).

The conceal mode becomes rather useful with it comes to mathematics:

\[
e^{ix} + \alpha - \beta
\]

is displayed as

eⁱˣ + α - β.

To answer your questions more directly:

What is special about these letters? Why does the syntax consider them different?

The only thing special about those letters are that Vim's syntax highlighting file provides functions to conceal those particular subscript letters with suitable Unicode glyphs.

Is there a flavor of TeX where the difference is meaningful?

Nope. It's all the same to TeX.

5
  • Great answer! Also pointed me to the g:tex_conceal option, which decides what gets concealed and what does not. Setting it to "" will make the weird highlighting disappear.
    – vlsd
    Commented Oct 9, 2013 at 18:19
  • do u know how to remove the difference between highlighting of _i and _j? it hurts!
    – Ayrat
    Commented Nov 7, 2015 at 15:50
  • 1
    @Ayrat In vim, run :help tex-supersub to learn how to specify which super- and subscript character should be concealed. See :help tex-conceal for more general information about how to control the concealment of other TeX-related entities.
    – godbyk
    Commented Nov 10, 2015 at 3:26
  • @godbyk which version do you have? do you have some tex plugins installed? my vim 7.4 does not have :help tex-supersub (with plugin latex-box)
    – Ayrat
    Commented Nov 11, 2015 at 10:29
  • @Ayrat I'm running vim 7.4.
    – godbyk
    Commented Nov 13, 2015 at 22:51

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .