Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am generating a pdf output with pdflatex with the following command in gVim:

:!pdflatex %

This command in turns executes the following in the Command Prompt:

cmd.exe /c pdflatex /testvim.tex

Now, the problem I'm having with this is that the pdf is outputted to the system32 folder:


How can I instruct pdflatex to generate the pdf in the folder where the tex file resides?

share|improve this question

Apparently you can use

-output-directory <wherever>

To get the directory of the current file, you'll need to use:


but you'll need to write a macro or a function that can evaluate that; something like:

map ,,p :exe "!pdflatex -output-directory " . expand('%:h') . " %"<CR>
share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .