Please find my minimal vimrc (whatever I use for Latex compilation)

"General "{{{
set nocompatible                     "  because vim is not vi
"set autowrite                       "  write on shell commands
"set autoread                        "  read on change outside vim
set spell spl=en_us                  "  Set Spell
set omnifunc=syntaxcomplete#Complete
set tags=tags;/
syntax enable
" let mapleader=","
set encoding=utf8

" VimPlug {{{
if empty(glob('~/.vim/autoload/plug.vim'))
  silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs
        \ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
  autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
call plug#begin('~/.vim/plugged')
Plug 'dense-analysis/ale'
Plug 'vim-latex/vim-latex'                      , {'for': 'tex'}                      "
Plug 'neoclide/coc.nvim'                      , {'branch':'release'}
Plug 'skywind3000/asyncrun.vim'
call plug#end()
filetype plugin indent on

"LaTeX {{{2
augroup FT_LaTex
  autocmd BufReadPost *.tex setlocal filetype=tex
  au FileType tex let b:ale_linters =  ['texlab']
  au filetype tex let b:ale_fixers = ['latexindent', 'remove_trailing_lines', 'trim_whitespace']  
  let g:tex_flavor = 'latex'
  let g:Tex_CustomTemplateDirectory='/home/rudra/Templates/Latex'
  " let g:Tex_DefaultTargetFormat = 'pdf'
  " let g:Tex_ViewRule_pdf = 'evince_dbus.py'
  " let g:Tex_Debug = 1
  " let g:Tex_DebugLog = '/tmp/vim-latex-suite.log'
  let g:Tex_FoldedMisc = 'preamble,<<<'
  au FileType tex inoremap "" ``"<++><esc>4hi
  au FileType bib inoremap "" ""<++><esc>4hi
  au FileType tex inoremap <<< %<<<
  au VimLeavePre  *.tex  exe "! latexmk -c"
  au filetype tex syntax region texZone start='\\begin{minted}' end='\\end{minted}'
augroup END

if match (&runtimepath, "coc.nvim") !=-1 
  let g:coc_start_at_startup = 0
  augroup coc
    autocmd VimEnter * :silent CocStart
  augroup end
  let g:coc_user_config = {
        \   'languageserver': {
        \     'latex': {
        \       'command': '/home/rudra/.local/bin/texlab',
        \       'ignoredRootPaths':['~'],
        \       'filetypes': ['tex', 'bib', 'plaintex', 'context'],
        \     }
        \   }
        \ }
  echom ('install coc.nvim')

" ALE {{{
let g:ale_sign_error = 'EE'
let g:ale_sign_warning = 'ww'
let g:ale_set_loclist = 0
let g:ale_set_quickfix = 1
let g:ale_fix_on_save = 1
" let g:ale_fixers = ['remove_trailing_lines', 'trim_whitespace'] 
" }}}

" AsyncRun {{{
" Quick run via <F10>
nnoremap <F10> :call <SID>compile_and_run()<CR><Esc>
inoremap <buffer> <F10> <Esc> :call <SID>compile_and_run()<CR><Esc>
function! s:compile_and_run()
  exec 'w'
  if &filetype == 'tex'
    exec "AsyncRun!  latexmk -pdflua -pvc --synctex=1 -shell-escape  %"
  elseif &filetype == 'sh'
    exec "AsyncRun! time bash %"
let g:asyncrun_open = 15

And a mwe.tex:

    Hello World
        Hello & World & \makebox[\linewidth][s]{\spaceout{0123456789}} \\\hline

The problem is, when I run from terminal, I get the error very neat and clean as:

! Undefined control sequence.
l.10 \thisiserror
! Undefined control sequence.
<argument> \spaceout 
l.13 ...akebox[\linewidth][s]{\spaceout{0123456789}}

But if I am compiling inside vim as

exec "AsyncRun!  latexmk -pdflua -pvc --synctex=1 -shell-escape  %"

in quickfix, I get not so helpful output:

mwe.tex|| Undefined control sequence.
mwe.tex|| Emergency stop.
mwe.tex|| ==> Fatal error occurred, no output PDF file produced!

If I add

au filetype tex set errorformat=%f:%l:%c:%m

in augroup FT_Latex, I am getting complete compilation, and not the error only.

What I can do?

Also, how I can check all the errorformat active in my vim.

The format I am looking for is: line no: Error

2 Answers 2


I think you misunderstand what 'errorformat' does.

It's not "please display errors like so", rather "here's what errors look like, please find them".

More precisely, each line of the output of makeprg is matched against each member errorformat.

Your example, %f:%l:%c:%m, works for an output that looks like:

file:3:2:this is an error message

As such a line can't be found in your output, no error can be extracted.

latexmk seems to be quite difficult to write an errorformat for, so you may want to try another tool for the job. vimwiki suggests rubber whith this errorformat:

setlocal errorformat=%f:%l:\ %m,%f:%l-%\\d%\\+:\ %m

Some help topics:


As Biggybi notes, there may be a misunderstanding as I'm not sure if you want the quickfix window to correctly interpret the output of latexmk or you want it to display the errors in a different way. If it's the latter, then you'll want to look at :h quickfix-window-function which enables you to customise this, although note that it is still a single line of text per error.

For latexmk, I use the following errorformat which was taken from a previous commit of the vimtex plugin:

setlocal makeprg=latexmk\ %:S
" https://github.com/lervag/vimtex/blob/98327bfe0e599bf580e61cfaa6216c8d4177b23d/compiler/latexmk.vim
setlocal errorformat=%-P**%f
setlocal errorformat+=%-P**\"%f\"
setlocal errorformat+=%E!\ LaTeX\ %trror:\ %m
setlocal errorformat+=%E%f:%l:\ %m
setlocal errorformat+=%E!\ %m
setlocal errorformat+=%Z<argument>\ %m
setlocal errorformat+=%Cl.%l\ %m
setlocal errorformat+=%+WLaTeX\ Font\ Warning:\ %.%#line\ %l%.%#
setlocal errorformat+=%-CLaTeX\ Font\ Warning:\ %m
setlocal errorformat+=%-C(Font)%m
setlocal errorformat+=%+WLaTeX\ %.%#Warning:\ %.%#line\ %l%.%#
setlocal errorformat+=%+WLaTeX\ %.%#Warning:\ %m
setlocal errorformat+=%+WOverfull\ %\\%\\hbox%.%#\ at\ lines\ %l--%*\\d
setlocal errorformat+=%+WUnderfull\ %\\%\\hbox%.%#\ at\ lines\ %l--%*\\d
setlocal errorformat+=%+WPackage\ natbib\ Warning:\ %m\ on\ input\ line\ %l%.
setlocal errorformat+=%+WPackage\ biblatex\ Warning:\ %m
setlocal errorformat+=%-C(biblatex)%.%#in\ t%.%#
setlocal errorformat+=%-C(biblatex)%.%#Please\ v%.%#
setlocal errorformat+=%-C(biblatex)%.%#LaTeX\ a%.%#
setlocal errorformat+=%-C(biblatex)%m
setlocal errorformat+=%-Z(babel)%.%#input\ line\ %l.
setlocal errorformat+=%-C(babel)%m
setlocal errorformat+=%+WPackage\ hyperref\ Warning:\ %m
setlocal errorformat+=%-C(hyperref)%.%#on\ input\ line\ %l.
setlocal errorformat+=%-C(hyperref)%m
setlocal errorformat+=%+WPackage\ scrreprt\ Warning:\ %m
setlocal errorformat+=%-C(scrreprt)%m
setlocal errorformat+=%+WPackage\ fixltx2e\ Warning:\ %m
setlocal errorformat+=%-C(fixltx2e)%m
setlocal errorformat+=%+WPackage\ titlesec\ Warning:\ %m
setlocal errorformat+=%-C(titlesec)%m
setlocal errorformat+=%-G%.%#

And also have the following in my latexmkrc:

$pdflatex = "pdflatex -file-line-error -interaction=nonstopmode %O %S"

This means that latexmk errors are interpreted correctly and displayed in the quickfix window, one error per line (which is how the quickfix window is intended to show errors) like so:


I'm afraid I don't use continuous compilation (-pvc) so I haven't tested how it would interact with that.

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.