Compiling Latex/Bibtex from Vim… without plugins

You’re probably better off using a plug-in. I did it manually, and I forget why. But here it is. Pretty simple once it’s all said and done, but it took me ages to figure out the bash/zsh code to make it work.

Step 1. Add the following functions to your bash/zsh/etc. env:

latte () {
s=${1%tex}pdf
pdflatex $1
open -a "Preview" $s
}

latte2 () {
s=${1%tex}pdf
t=${1%tex}aux
pdflatex $1
bibtex $t
pdflatex $1
pdflatex $1
open -a "Preview" $s
}

Step 2. Add the following to your vimrc:autocmd FileType tex,latex noremap gl :w<CR>:!latte %
autocmd FileType tex,latex noremap gb :w<CR>:!latte2 %

Step 3. When you wish to compile your latex file, type gl. If you wish to compile your bibtex too, type gb.

Leave a comment