I am using LaTeX in Vim with VimLaTeX-Suite and i just started using Sage and i want to implement SageTex in my documents, but everytime i want to compile a have to follow this process in the terminal

$ pdflatex <doc.tex>

$ sage <doc.sagetex.sage>

$ pdflatex <doc.tex>

Ref:commands to compile from terminal

I want to run a command this \ll one which compiles the files to pdf.

I saw that you can make something like this:

map <leader>ls :w<cr><leader>ll<cr>!sage %.sagetex.sage<cr><leader>ll

or this

<leader>ls :w<cr>:!pdflatex %<cr>:!sage %.sagetex.sage<cr>:!pdflatex %

in the ~/.vim/ftplugin/tex.vim or the ~/.vimrc file but it doesnt work for me and i dont know what to do?

Can someone give me a hint? plz. :)

  • I think you're missing a colon before !. Does that work?
    – Dai Bowen
    Jan 31, 2019 at 15:05
  • No i tried this <leader>ls :w<cr>:!pdflatex %<cr>:!sage %.sagetex.sage<cr>:!pdflatex % and still no output Feb 10, 2019 at 11:26

1 Answer 1


Had the same issue. I put this in my .vimrc, it works for me.

    au BufReadPost *.tex nnoremap <silent> <leader>sx
     \ :! pdflatex % &&
     \ sage %:r.sagetex.sage &&
     \ pdflatex %<cr>

You must log in to answer this question.

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