Vim LaTex
I noticed that in the past I produced several posts about combining LaTex and Emacs. While I do like Emacs and respect it’s formidable power I do not consider myself an Emacs user. Most of my day-to-day work is done in Vim which brings different kind of editing power to the table. Emacs is a lisp based framework for building text editing applications - fully programmable, easily customizable and almost endlessly extensible. The power of Emacs comes from what it can do. Vim’s power stems from what it does - and that is providing very powerful and yet simple modal text editing environment. I wanted to say intuitive, but yeah - that would be a lie. Vim is powerful because it allows you to accomplish just about anything in 3-4 keystrokes by chaining and combining simple commands.
Using Vim makes editing text much simpler and easier. It removes a lot of key-presses and movements. Let me give you an example - in a typical coding session you may want to copy the current line, and paste it below. Assuming your cursor is in the middle of the line how would you go about accomplishing it? Typically you would do:
- Hit Home to skip to the beginning of the line
- Hold shift and hit End to highlight the line
- Press Ctrl+C to copy the line
- Hit End again to put the cursor at the end of the line
- Hit Enter to insert a new line
- Press Ctrl+V to paste the line
How do you do it in Vim?
- Press the following keys in a sequence: yyp
That’s it. You want to paste the line 3 times? Do yy3p. This is the power you get when you use Vim. Of course die-hard emacs fanboys will remind me that one could always use Emacs’ VIP mode which emulates vi’s modal editing features. And they would be absolutely right. As I said, Emacs is a framework for building editors rather than an editor. So when you launch it in VIP mode you are really using Vi with the lisp powerhouse underneath it.
In theory you could combine the neat features of AUCTex on Emacs and the power the VIP mode gives you to get the best of both worlds. But if you don’t need these features - if you are a Vim purist or if you just need a simple modal text editor I have a nice alternative for you. It’s called VimLaTex.

While it does not have the nice rendering features of AUCTex, VimLaTex is a must-have if you are planning to use Vim to edit LaTex files. The package itself is tiny - you just drop few hundred KB into your .vim directory and add few lines to your .vimrc.
The suite will add bunch of useful menus to your toolbar:
These menus are your standard IDE like features - for example options for inserting packages, or snippets of code for special environments and etc.. A lot of the entries come with predefined key-bindings which make your life much easier. For example:
- To compile your file do: \ll
- To view compiled file do: \lv
You can set the preferred format for both options above by invoking :TTarget. It works like a charm both on Windows and Linux when I tried it.
VimLaTex also uses an interesting concept of placeholders. Whenever you use it to generate snippet of code, it will put funny looking character sequences inside of it. They may look silly until you realize how useful they are. For example let’s say you want to insert a figure:
\begin{figure}[h] \centerline{\psfig{figure=«eps file»}} \caption{«caption text»} \label{fig:«label»} \end{figure}«»
The placeholders are there to make your life easier. When you press Ctrl+J vim will jump to the first «» delimited sequence and select it. This way you can just type over it. Press Ctrl+J again (while still in insert mode) and you will jump to the next one. How awesome is that?
If you are a Vim lover who also happens to use LaTex or a LaTex user who loves Vim definitely check this one out.
Related Posts:

October 20th, 2008 at 3:45 pm (10439) [Quote]
“The power of Emacs comes from what it can do. Vim’s power stems from what it does.”
I think I just achieved enlightenment. What a great piece of insight.
Posted usingOctober 20th, 2008 at 4:31 pm (10441) [Quote]
So wait… what do you do if you just want to type “yyp”?
Honest question - I’ve never had cause to use any text editor more complex than Notepad (I know, not really a text editor in the same sense, but you know what I mean)
Posted usingOctober 20th, 2008 at 4:41 pm (10442) [Quote]
btw, duplicating a line is a single keypress (ctrl+d) in notepad++ or visual studio with c++ keybindings.
Posted usingOctober 20th, 2008 at 5:18 pm (10443) [Quote]
@Paul:
@Matt`: Oh, you first enter the edit mode by typing i. Once you are in edit mode you can type normally. Once you type something you hit Esc to go back to command mode where you can use single keystrokes to perform various functions.
@Mirko: Neat. I didn’t know that. A lot of IDE’s use Ctrl+D to mean “comment-out the highlighted block” though so this is going to be confusing.
Still, in Vim I can apply similar philosophy for selecting and copying whole paragraphs or functions. For example y}p will duplicate the whole paragraph. y2}p will duplicate the next paragraph and etc…
Posted usingOctober 21st, 2008 at 4:38 pm (10454) [Quote]
Luke, I don’y believe that VIP mode has been current since the 90’s
. Currently what is in use is viper, which is more complete and more configurable, (it makes it easier to access Emac’s standard feature set while in Vi mode) In addition, there is a nice patch: Vimpulse, which does a nice job imitating Vim, not just Vi the difference is tangible any serious Vim user (such as myself.)
Also, I probably wouldn’t use y}p to duplicate a paragraph, as it won’t work if you start with the cursor in the middle. You’d do better to say {y}p, or maybe {v}k$yP if you want to preserve the last blank line. Of course, this starts to get complicated, so you might want to use nmap to map it or something: