I'm not sure if it has always happened or its just recent, but vim auto-compiles on each save (:w). I would like to only manually compile (I use a hot-keyed pdflatex command instead).

I've had a quick google and read through the manual and nothing has jumped out at me. Anyone know how to do this?

Update: Relevant lines in vimrc

Plug 'vim-latex/vim-latex'
let g:tex_flavor='latex'
" OPTIONAL: This enables automatic indentation as you type.
filetype indent on
" `Ctrl` + `P` compiles latest save of current .tex file to pdf
autocmd FileType tex nnoremap <c-p> <ESC>:!pdflatex %<CR>

NB: Plug-in manager is junegunn/vim-plug

Update 2: Turns out I did it back when I first got latex.. Really should be keeping a record of changes I make

  • Are you sure this is vim-latex? Can you provide a link to the plugin that you are using? Mar 2, 2019 at 18:14
  • @Karl vim-latex/vim-latex edit: ... I'm a goober and can't read instructions/remember how to SE
    – ljden
    Mar 2, 2019 at 22:10
  • 1
    I cannot confirm that vim-latex has the functionality of automatically compiling on :w. Could you try a minimal installation as described here: vi.stackexchange.com/questions/17945/…?
    – Hotschke
    Mar 3, 2019 at 11:37
  • I have a suggestion for your mapping: Use autocmd FileType tex nmap <c-p> <Plug>Tex_Compile instead of yours. The quickfix list is then automatically filled with LaTeX errors which makes it easier to navigate to them. For example, try it with a Hello World file and add deliberately an error by inserting _ outside of a math environment. After compilation your cursor should immediately be placed on the line with the _.
    – Hotschke
    Mar 3, 2019 at 11:41
  • 1
    I should add following to my previous comment: to generate a pdf immediately on windows or linux, add following to your vimrc: let g:Tex_DefaultTargetFormat = 'pdf'.
    – Hotschke
    Mar 3, 2019 at 11:51

1 Answer 1


Debugging Autocmds

If something happens automatically for a certain command (here :write) in vim, an autocmd might be the reason for this.

If you already know the event of the autocmd, you can see the autocmds with

:autocmd <Event Name>

as described under :h autocmd-list.

In your case likely candidates are

:autocmd BufWritePost
:autocmd BufWrite
:autocmd FileWritePost
:autocmd FileWrite

To see also the filenames where these autocmds are defined, run

:verbose autocmd <Event Name>

A list of events used by the autocmds can be found under

:h autocmd-events

Since this list is quite long and you might have no clue where to start, a second method is to invoke your command prefixed with :9verbose. In your case

:9verbose write

The count 9 is important so that also autocmds are listed. This is described under :h 'verbose'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.