Shell Script for 'Latex'-ing from vim

I am a vim loyalist.

Features in Emacs like compiling latex code and viewing the output without having to switch to the terminal is awesome. However, having used vim (and recently gvim) for more than 5 years, its easier for me to write scripts for vim to implement the cool features of Emacs rather than switch to Emacs. Below is a simple shell script to compile latex document and show the output without leaving the editor.


 #! /bin/sh
 source=$1
 infile=${source%.tex}
 latex $infile
 bibtex $infile
 latex $infile
 latex $infile
 dvips $infile.dvi
 ps2pdf $infile.ps
 evince $infile.pdf

You can use pdflatex instead of latex. Also, I use evince to view the pdf because any update in the file is updated in the viewer without having to restart it (unlike acroread). The script (I call it compile_latex.sh) needs to be saved in a directory included in the PATH.

Now comes the vim part. The following line needs to be added in .vimrc (or .gvimrc).

map :!compile_latex.sh %

I am now looking for a good psychiatrist program to integrate with vim; helps to vent out frustration :-).

Comments

Popular posts from this blog

One day in Mylapore

Is Google+ a Facebook Killer?

I love to visit Madras