0

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

ljden
  • 378
  • 1
  • 9
  • Are you sure this is vim-latex? Can you provide a link to the plugin that you are using? – Karl Yngve Lervåg Mar 02 '19 at 18:14
  • @Karl vim-latex/vim-latex edit: ... I'm a goober and can't read instructions/remember how to SE – ljden Mar 02 '19 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: https://vi.stackexchange.com/questions/17945/vim-latex-installation-confusion/17946#17946? – Hotschke Mar 03 '19 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 03 '19 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 03 '19 at 11:51
  • I couldn't figure out what was wrong, so I did some digging through the plugin file system, and found a file that had been edited 3 days after downloading the plugin (last mod date was the key). At the bottom of one of the files I found the culprit! au BufWritePost *.tex silent call Tex_RunLaTeX() from Vim tips wiki – ljden Mar 05 '19 at 23:53

1 Answers1

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'

Hotschke
  • 4,740
  • 26
  • 37