I've always used SublimeText for writing and compiling my LaTex files, but recently I've moved the majority of my code to Vim, and I would like to do the same thing with LaTex documents. I am on OSX Sierra, with the MacTeX package, and I've tried to use this plugin, but it gives me some errors.

My question is, how can I build a working environment for LaTex development on Vim?

  • 1
    vim-latex.sourceforge.net – Henri Menke Feb 13 '17 at 9:50
  • 1
    MacVim works pretty well out of the box for Latex development. I tried vim-latex but found it much too fussy and much too complicated, so I deleted it. Syntax high lighting just works. For compiling I just do <esc>!xelatex %. I use Skim for previewing PDF output, with the option to automatically update. You can open Skim with <esc>!open -a Skim %:r.pdf. – Thruston Feb 13 '17 at 10:47
  • 1
    I highly recommend github.com/lervag/vimtex -- much more lightweight than vim-latex, and actively maintained (based on LaTeX-Box). The documentation contains instructions to set it up to work with Skim, including forward and backward sync. – Christian Clason Feb 13 '17 at 11:06
  • I'm currently trying vim-latex as suggested by @HenriMenke . It seems a very sound and complete plugin, I wonder if it can do a live-preview of the page like the plugin citated in my question. – g_rmz Feb 13 '17 at 15:06
  • 1
    Generally I think just use a PDF viewer which doesn't lock the PDF (Okular, Sumatra for example) and have that open in a window next to vim and manually compile regularly (this has always done the job for me), vim-latex has no such . If you want help with the vim-latex-live-preview plugin - what have you done to try and set it up and what are the errors you are receiving? – Dai Bowen Feb 13 '17 at 15:29

I'm really liking the example by @Thruston in the comments above, so with all credit to their answer, I'd like to expand it here including installation and setup steps.

Combined with ideas from: Dianaci's Vim Setup, I will outline the 5 minutes of steps it took to get my system optimal.

  1. Install Skim
  2. Open Skim and go to Preferences > Sync and check "Check for file changes" and "Reload automatically"
  3. Install MacTex which will provide xelatex, latex, etc., if you don't already have xelatex on your system.
  4. Create a VIMRC file at ~/.vimrc if you don't have one already.
  5. Add the following:


" Mappings for compiling Latex file
autocmd FileType tex nmap <buffer> <C-T> :!xelatex %<CR>
autocmd FileType tex nmap <buffer> T :!open -a Skim %:r.pdf<CR><CR>

These create commands for quickly running xelatex from within VIM or MacVIM by pressing Ctrl-T and for opening the resulting PDF in Skim (Shift-T).

Once you have completed those steps, open VIM or MacVim (be sure to close and re-open if you just created your .vimrc file so that they pick up the changes). Then open a .tex file and hit Ctrl-T to compile it to PDF. The xelatex output will require you to hit return to get back to the VIM interface. Then hit Shift-T to open the PDF in Skim.

Skim will update automatically from that point on whenever you hit Ctrl-T to recompile the .tex file.

Thanks to @Thruston from the comments above and to DianaCai for the additional VIM command ideas. Hope you enjoy. I certainly do.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.