Wikia

Vim Tips Wiki

Changes: Text object for formulas in Latex

Edit

Back to page

(Change <tt> to <code>, perhaps also minor tweak.)
(Fix my broken edit.)
 
Line 15: Line 15:
 
For information on operator pending commands and omap see [[Mapping keys in Vim - Tutorial (Part 1)#Operator pending mode maps|here]].
 
For information on operator pending commands and omap see [[Mapping keys in Vim - Tutorial (Part 1)#Operator pending mode maps|here]].
   
Install {{script|id=3130|text=CountJump] and add the following code to your <code>ftplugin/tex.vim</code> file.
+
Install {{script|id=3130|text=CountJump}} and add the following code to your <code>ftplugin/tex.vim</code> file.
 
<pre>
 
<pre>
 
call CountJump#TextObject#MakeWithCountSearch('<buffer>', '$', 'ai', 'v', '\$', '\$')
 
call CountJump#TextObject#MakeWithCountSearch('<buffer>', '$', 'ai', 'v', '\$', '\$')

Latest revision as of 07:30, July 13, 2012

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.

For information on operator pending commands and omap see here.

Install CountJump and add the following code to your ftplugin/tex.vim 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.

CommentsEdit

Around Wikia's network

Random Wiki