hwong557
hwong557

Reputation: 1439

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

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!

Upvotes: 8

Views: 5118

Answers (5)

Piyush Bansal
Piyush Bansal

Reputation: 41

You can try:-

:w | !pdflatex "filename"

I believe this will work fine in your case.

Upvotes: 0

Fredrik Erlandsson
Fredrik Erlandsson

Reputation: 1527

@dc46and2 Your command should be:

autocmd FileType tex call Tex_MakeMap('<leader>ll', ':update!<CR>:call Tex_RunLaTeX()<CR>', 'n', '<buffer>')
autocmd FileType tex call Tex_MakeMap('<leader>ll', '<ESC>:update!<CR>:call Tex_RunLaTeX()<CR>', 'v', '<buffer>')

AFAIK, " are used for comments in vim.

Upvotes: 1

dc46and2
dc46and2

Reputation: 167

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>')

Upvotes: 2

hwong557
hwong557

Reputation: 1439

I have since moved on from latex suite and i am now using latexmk which works really well.

Upvotes: 1

skeept
skeept

Reputation: 12423

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.

Upvotes: 10

Related Questions