Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I make vim-latex compile correctly without having to save?

Tags:

vim

latex

I just started using Vim-LaTeX.

The default dvi output didn't work for me, so I changed the default to pdf by adding "let g:Tex_DefaultTargetFormat = 'pdf'" to my tex.vim.

The only problem is that I need to save my document first (:w) before compiling it (\ll) and viewing in in Evince (\lv). If I do not save it, and run \ll and \lv, latex is run on the saved file before I started editing it, and not on the buffer containing my edited file.

How do I make it so that vim saves my file and compiles my document when I hit \ll? Thanks!

like image 714
hwong557 Avatar asked Sep 18 '10 06:09

hwong557


2 Answers

this is not the perfect solution but it will work, define a new map in your .vimrc:

map <f2> :w<cr><leader>ll

this works but there should exist a cleaner way of doing this.

like image 181
skeept Avatar answered Sep 20 '22 11:09

skeept


This does specifically what you asked. Add the following to your .vimrc or equivalent:

autocmd FileType tex call Tex_MakeMap("<Leader>ll", ":w <CR> <Plug>Tex_Compile", 'n', '<buffer>')
autocmd FileType tex call Tex_MakeMap("<Leader>ll", "<ESC> :w <CR> <Plug>Tex_Compile", 'v', '<buffer>')
like image 23
dc46and2 Avatar answered Sep 18 '22 11:09

dc46and2