Open huijunchen9260 opened 4 years ago
In case onething
or something else
contained operators like +
or -
, the meaning could be confused, but if we wrap in parentheses like (onething) / (something else)
, I think it could be a nice feature.
Thanks for your suggestion. I also like the feature, but I have no idea how to implement it.
I've been hacking away at this, and so far I can conceal \frac
and leave the concealed line as {onething}/{something else}
using
syn match texFrac '\\frac' containedin=texFrac conceal
syn match texFrac "}\zs \ze{" containedin=texFrac conceal cchar=/
syn region texFrac start=/\\frac{/ skip=/} {/ end=/}/ contains=texFrac,texMathSymbol containedin=@texMathZones,texStatement transparent
I could not find a way to conceal }{
as }/{
(that would mean matching zero characters) so I'm having to write \frac{a} {b}
instead of \frac{a}{b}
.
The above code produces
Also it would be nice to get it to color the \frac
and the brackets.
syn match texFrac '\\frac' containedin=texFrac conceal syn match texFrac "}\zs \ze{" containedin=texFrac conceal cchar=/ syn region texFrac start=/\\frac{/ skip=/} {/ end=/}/ contains=texFrac,texMathSymbol containedin=@texMathZones,texStatement transparent
This is really nice. Could you tell me how to implement this in the file? I put those quoted code into the /after/syntax/tex.vim
and somehow it is not working.
Thanks! I put it at the end of that file in this plugin's directory. If you have vimtex or other latex plugins try disabling them one by one to see if the texZones collide or something.
Also you can see if the texFrac
region is recognized by appending
hi lin texFrac Error
to the previous lines. It should highlight at least the \frac{
part.
Keep in mind that for now it only works when writing \frac{a} {b}
, with a space in between the }{
.
Dear @KeitaNakamura:
It actually shouldn't an issue but just a feature request. I wish it is possible to hide
\frac{onething}{something else}
intoonething / something else
. I simply think that would be super cool.