-
Notifications
You must be signed in to change notification settings - Fork 407
Text object for a symbol and its sub- and superscripts #1779
Description
Is your feature request related to a problem? Please describe it.
Anyone who's used TeX for some time will have used sub- and superscripts like $ Cx_0^{1/2} y $. Since the whole of x_0^{1/2} is semantically one object, it would be extremely convenient to have a text object corresponding to it, say ax. (The exact binding is immaterial, of course.)
Describe the solution you'd like
With the cursor anywhere between x and }, inclusive, in the example above, vax selects x_0^{1/2}.
For nested su*scripts, say, e^{ a x^3} with the cursor anywhere in x^3, vax selects x^3, on e^ it selects e^{ a x^3}, and with the cursor inside the {}, va{ax also selects everything.
For something like \sin^2 x, vax could be used to select \sin^2.
Describe alternatives you've considered
For me, this would mostly replace various mashing of a{WB fF etc.
The vim-textobj-user plugin can probably be used to implement this, but since it is such a common task when editing TeX, I think it makes sense for it to be provided in vimtex. We already have ac, a$ etc.
One possibility would be an optional dependency on vim-textobj-user.