Skip to content

Add magic comment to switch on/off the "error" highlighting of underscores #3082

@Rmano

Description

@Rmano

Underscores are marked as errors (in this case, I have hi Error guifg=black guibg=orange gui=none set up because the standard error highlighting in my colortheme is too bland):

Image

which is good. But sometimes you are defining, for example, pieces of codes in a \newcommand or similar:

 %%
\newcommand\npnblock[5]{% block to draw the BJT.
    % #1 -> label
    % #2 -> volts in
    % #3 -> Ib
    % #4 -> Vce
    % #5 -> Ic
    node[left]{\qty{#2}{V}} to[R=$R_B$, o-, f_=\qty{#3}{\mA}]
        ++(1.5,0) node[npn, anchor=B](Q#1){}
        (Q#1.E) node[ground]{}
        ([xshift=0.5cm]Q#1.C) to[open, v=\qty{#4}{V}] ([xshift=0.5cm]Q#1.E)
        (Q#1.C) to[generic=$R_L$, f<_=\qty{#5}{\mA}] ++(0,2)
        node[vcc]{$+V_{CC}$}
    }
%%
%%

...and you have this:

Image

Clearly, there is no way to automatically differentiate the two cases (unless removing the error in every macro replacement text, which I think is not correct).

Maybe there could be a kind of magic %text underscore begin/end (or whatever name, don't trust me on naming things) to switch the highlighting, similar to #3080 ?

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions