Vim as my LaTeX editor

(λx.x)eranga
Effectz.AI
Published in
3 min readJul 4, 2017

Marriage with Vim

I’m using Vim as an IDE for Golang, Python, Scala and Erlang kind of developments. Also using ideavim plugin which enables me to use vim key movements and features in Intellij IDEA and Android Studio. I would like to say I’m quite addicted to vim and quite comfortable with it. So I decided to use vim as my LaTeX editing tool.

With this post I will give background information about LaTeX, vim plugins and how I have setup vim as a LaTeX editor.

LaTeX

About LaTeX

LaTeX is a document preparation system for high-quality typesetting. It can also introduce as a document markup language. LaTeX is based on TeX.

About TeX?

TeX is a very powerful typesetting language that can be used to write almost anything. It was designed and developed by Donald Knuth, a professor at Stanford University. TeX is used heavily in the academic and scientific world.

Install LaTeX

The LaTeX version available for Mac is MacTeX. You can find the installation information from below.

  1. Mac OS - http://www.tug.org/mactex/
  2. Linux - http://linuxandfriends.com/install-latex-in-ubuntu-linux/
  3. Windows - http://www.tug.org/protext/
  4. http://latex-project.org/ftp.html

LaTeX and Vim

I’m using vim as my LaTeX editor. I have setup vim to view live preview of the output PDF of my LaTeX files. I have done this via using vim plugin called vim-latex-preview.

Install plugin

I have installed the vim-latex-preview plugin by using vim pathogen. Follow this vimcast to get more information about setting up vim plugins with pathogen. Following is the command to install the plugin.

# keeping all my vim configs in ~/.vim directory 
cd ~/.vim
# install plugin as git submodule
git submodule add https://github.com/xuhdev/vim-latex-live-preview.git bundle/vim-latex-live-preview

I have already configured all of vim plugins with git submodule and pathogen. I’m keeping the vim configurations on my github. You can directly use it if you want(it contains all the vim plugins that I’m using including vim-latex-preview).

Plugin configuration

There are few configurations that needs to with vim-latex-preview plugin. I have defined these configurations on my vim configuration file at ~/.vimrc file.

First I have set the vim option updatetime to a smaller value, which is the frequency that the output PDF is updated. This helps to get the live preview of the editing LaTeX file.

autocmd Filetype tex setl updatetime=1

Then I have defined the PDF previewer. I’m using Preview viewer on Mac as my PDF previewer.

let g:livepreview_previewer = 'open -a Preview'

More informations about preview configuration can be find from here. Following is how my ~/.vimrc files looks with vim-latex-preview plugin configurations.

Example

Following is an example document I have created from LaTex with the help of vim-latex-preview.

LaTeX file

I have created a LaTex file called senz.tex

Preview

When editing this file with vim use below command to get the preview of the document.

:LLPStartPreview

This command will generates a PDF preview of the document and open it via Preview viewer on Mac. Following is how it looks like

Live preview

When you changing the text in your LaTeX document, you can see the live update of the changes (in PDF document) via Preview viewer

Reference

  1. http://computers.tutsplus.com/tutorials/the-beginners-guide-to-using-tex-in-os-x--mac-45177
  2. http://www.topbug.net/blog/2013/06/13/live-preview-of-latex-in-vim/
  3. LaTeX templates — http://www.latextemplates.com/
  4. Online LaTeX editor — https://www.writelatex.com/

--

--