Setup latex on vim

This guide will show you how to turn vim into a latex editor. We will install the latex-suite tool and then create a Makefile that allows us to compile latex within vim.

1. Install texlive:

sudo apt-get update
sudo apt-get install texlive-full

2. Install latex-suite:

Don’t install latex-suite from Vundle. Otherwise, the F9 key will not work.

3. Install gvim (optional):

sudo apt-get install vim-gnome

4. Compile latex and generate .pdf file from vim:

Use rubber

sudo apt-get update
sudo apt-get install rubber

Create a makefile

%.pdf: %.tex $(DEPENDS)
rubber -f --pdf -s $<
rubber-info --check $<
rm -rf *.log *.aux *.dvi   # remove unnecessary files!

Add these lines to ~/.vim/ftplugin/tex_latexSuite.vim

setlocal errorformat=%f:%l:\ %m,%f:%l-%\\d%\\+:\ %m
if filereadable('Makefile')
setlocal makeprg=make
exec "setlocal makeprg=make\\ -f\\ $PATH_TO_LATEX_MAKE_FILE/\\ " . substitute(bufname("%"),"tex$","pdf", "")

Replace $PATH_TO_LATEX_MAKE_FILE accordingly with path to your

To compile enter :make  in vim.