Latex and Vim usage

Verhogen picture Verhogen · Sep 16, 2010 · Viewed 32.7k times · Source

How can I use Latex effectively in VIM?

Is there a way to configure compile errors by highlighting the line in vim?

I have syntax highlight. What are other recommended add-ons? Is a makefile the recommended way to compile a latex file to pdf?

TexWorks lets you open and replace the opened pdf everytime it's recompiled. Is there a plugin to do something similar in vim?

Answer

MrException picture MrException · Oct 5, 2010

I've just begun playing around with LaTeX-Box. It seems like a good plugin. I, also used VIM-LaTeX for a while, but I didn't really like the key mappings, and it seemed a bit to heavyweight as Jeet described.

I like LaTeX-Box so far because it used latexmk to compile, which is what I was using anyway. Latexmk will sit in the background and watch your .tex file for changes, and then automatically compile for you. And if you use a pdf viewer which refreshed changes (such as evince on Linux) you can see updates every time you change. Adding

let g:LatexBox_latexmk_options = "-pvc -pdfps"

to my .vimrc got latexmk working properly. You also need the latexmk script somewhere on you PATH. The key mapping to start latexmk is the same as Vim-Latex's compile: '\ll' (that's lowercase LL).

I also use SuperTab plugin for completions, which is great. And I took the dictionary files from Vim-LaTeX so I have a ton of auto completion words to use. This dictionary file is: ftplugin/latex-suite/dictionaries/dictionary in the vim-latex files. What I did was copy this file into ~/.vim/dictionaries/ and renamed it 'tex' then I added these lines to my .vimrc file:

set filetype on
au FileType * exec("setlocal dictionary+=".$HOME."/.vim/dictionaries/".expand('<amatch>'))
set complete+=k

Then if I type the beginning of a latex command and hit 'tab' I will get a list of completions. Pretty handy. BTW that 'au' command in the vimrc will also load dictionaries for any other filetypes if you want. A useful trick.