I can't seem to find this option in the documentation. Is there a way to not freeze vim while the compilation is going on? What I would like is to say type "\ll" and have vim-latex run the compilation in the background, and provided there are errors, bring up quickfix.

Is that possible? Easy?

  • I don't use vim-latex but another plugin. Presumably somewhere in the vim-latex configuration you have a line like let g:Tex_CompileRule_pdf = 'pdflatex -synctex=1 --interaction=nonstopmode $*'. If so simply putting this into background should be enough: let g:Tex_CompileRule_pdf = 'pdflatex -synctex=1 --interaction=nonstopmode $* &' – user30471 Apr 30 '15 at 16:07
  • @Andrew actually this won't background the compilation unfortunately.... – hbetx9 Apr 30 '15 at 18:11

Vim is known to be bad at asynchronism, but plugins exist such as AsyncCommand allowing you to run commands in the background and see the output in a split once the command finished. AsyncCommand comes with an AsyncMake command, which can be used to make asynchronously. Therefore, in my vimrc I use :

noremap <leader>mm :AsyncMake<cr>

to map <leader>mm to asynchronous make, and

:autocmd BufEnter *.tex let &makeprg="latexmk -e '$pdflatex=q/pdflatex -synctex=1 -interaction=nonstopmode/' -pdf ".expand("<amatch>")

to set the make program to latexmk when I open tex files.

| improve this answer | |
  • 1
    This is great, but doesn't completely address the question. Can someone with experience with vim-latex suite chime in on where the edits need to be made to incorporate this? I would have preferred a solution that doesn't add yet another plugin to the mix if one is available. – hbetx9 Apr 30 '15 at 16:00
  • In particular, there is a way to background the command by adding & to the end of the rule, I just don't know where to add it so that \ll backgrounds the compilation – hbetx9 Apr 30 '15 at 16:04
  • The background is obtained via AsyncMake, which itself runs the make command in the background. The solution I propose would also compile any project with regular make in the backgound. I would rather use one global tool to background everything, rather than let every plugin cook its onwn solution, but I admit this is my own choice. – Vincent Nivoliers Apr 30 '15 at 16:06

AsyncCommand requires vim to be compiled with clientserver, which may or may not require a new compilation, and definitely will for those of us running Cygwin (after installing Cygwin/X).

An alternative that worked right away for me was the dispatch plugin, which provides the Start! command. I have the following in my vimrc:

map <leader>lr :w<CR>:Start! latexmk -pdf -pdflatex="pdflatex --shell-escape \%O \%S" % && latexmk -c %<CR>

This allows me to skip manually writing the file before compilation, and also cleans up after compilation (the latexmk -c command). A simpler variant would be

map <leader>lr :Start! latexmk -pdf % <CR>
| improve this answer | |

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.