- 0 Talk
-
Text object for formulas in Latex
In Latex, in-text formulas are surrounded by a pair of $ signs. The following plugin plus bindings allow operation on these formulas using the usual syntax for text objects in Vim. This allows for quick yanking, changing and deleting of such formulas which are very common tasks when writing mathematical text in Latex.
First, if you don't know what operator pending commands and omap are, see Mapping_keys_in_Vim_-_Tutorial_(Part_1)#Operator_pending_mode_maps for an overview.
Next, install the CountJump plugin. Then add the following code into your tex.vim ftplugin file.
call CountJump#TextObject#MakeWithCountSearch('<buffer>', '$', 'ai', 'v', '\$', '\$')
Now you can yank, delete, etc entire formulas using i$ for interior and a$ to include the bounding dollar signs.
For example, if you put the cursor inside a formula and type yi$, this will yank the interior of the dollar signs. Typing da$ will delete the entire formula including the dollar signs.