<leader>ll compiles the current file, but I'd like it to also write the current file before it does that. Personally, I don't understand why this is not default behavior. When would one ever wish to make some changes and then not have them included in their next compile?

I've tried adding exec 'w'.mainfname to vim-latex's main compile function Tex_CompileLatex(), which is defined in compiler.vim, but this doesn't work.


Not a specialist at all but here is the solution I have found for myself: Write a function (for instance in .vim/ftplugin/tex_latexSuite.vim ) and call it with an other key.

function! SaveAndCompile()
    call Tex_CompileLatex()  "defined in latex-suite/compiler.vim

nnoremap <Leader>f :call SaveAndCompile()

Of course you can change <Leader>f to something else.


Not exactly what you're asking for, but you could just use the normal vim command-line history to quickly write and compile a file from vim with one command similar to the following:

:w| ! xelatex %

Once that is the last command starting with :w in your command-line history you can write and compile your file in just four keystrokes: (Assuming you're in normal mode):

  1. :
  2. w
  3. [arrow up]
  4. enter.

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.