Wikia

Vim Tips Wiki

Watchlist Recent changes

Text object for formulas in Latex

Tip 1644 Printable Monobook Previous Next

created January 16, 2010 · complexity basic · version 7.0


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.

Pages on Vim Tips Wiki

Add a Page
1,586pages on
this wiki
Advertisement | Your ad here

Latest Photos

Add a Photo
71photos on this wiki
See more >

Recent Wiki Activity

See more >

Around Wikia's network

Random Wiki