Suppose in a latex file, I have a line

$X_{i_{j}}$ and $Y^{i_{k}}$

My goal is to define a text object in VIM for the subscript, i.e. _{i_{j}}, and superscript, i.e. ^{i_{k}}.

I was reading this wiki page. It requires more knowledge about command-line mode than I currently have.

For subscript, I was thinking the ex command should start by finding _, then move the cursor to its immediately right, and finally find the paired brace using % in normal model. I do not know how to write this up in ex command.

  • 1
    You might want to have a look at vim-text-object it is a plugin which allows you to easily define custom text objects.
    – statox
    Oct 23 '17 at 9:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.