Vim Tips Wiki

Duplicate tip

This tip is very similar to the following:

These tips need to be merged – see the merge guidelines.

Tip 1575 Printable Monobook Previous Next

created 2008 · complexity basic · author Bmearns · version 7.0

The errorformat (or efm) option is a comma-separated list of scanf-style format strings that are used with QuickFix to extract information like file name, line number, column number, etc, from errors and warnings generated with :make. If an error/warning message in the quickfix window matches one of your error formats, you can select it (double click in gvim, or press Enter on the line) to jump to the correct place. It also provides some simple reformatting and highlighting to standardize the display of recognized messages. :help 'efm'

Vim comes preloaded with some good defaults. You can use the set errorformat command in (for instance) your vimrc file to add more for tools you use. If you use the "+=" operator for the assignment, it will append the text to the current value, separated with a comma, as required for the errorformat.

If some builtin format bugs you, you could be tempted to copy the default errorformat and remove the annoying format (good luck to escape all the must-be-escaped characters). Or you could use the "-=" operator, e.g. "set errorformat-=%f:%l:%m"

Since compilers and other programs generate messages according to their own rules, there are a multitude of error formats that could be useful. Some are listed here.

C, C++, gcc[]

Assert messages are like: prog: some_file.c:16: some_func: Assertion `val == 0' failed. This pattern should be prepended to have precedence over other error patterns.

set errorformat^=%*[^:]:\ %f:%l:%*[^:]:%m " match libc assert

"In file included from":

let &efm .= ',%+GIn file included from %f:%l%*[\,:]'


let &efm .= ',' appends a comma ',' to option (not variable) "efm"

"%+G" means use all string as message. It is used instead %m.

Raw "let" assigns variable. ".=" appends string.


The free alternative to LEX, a lexical parser generator. Error messages are like: "somefile.l", line 15: rule cannot be matched.

set errorformat+=%*[\"]%f%*[\"]\\,\ line\ %l:\ %m

In case the message looks like "calc.y:64.7-23: error: some error", you should use this one instead:

set errorformat+=%f:%l.%c-%*\\d:\ %t%*[^:]:\ %m


The GNU bison parser generator (similar to YACC) generates a couple of different types of errors. They start with the file name, then a colon. If available, the linenumber comes next, followed by a dot (period) and the column number. If appropriate, a dash and then another column number (giving a column range) follows, and then a colon, space, and the error message.

set errorformat+=%f:%l.%c-%*[0-9]:\ %m
set errorformat+=%f:%l.%c:\ %m
set errorformat+=%f:\ %m

Texas Instruments cl2000 compiler[]

This is the C-compiler and linker that's used for some Texas Instruments DSP microprocessors. Error format is like "file.c", line 17: some error message.

set errorformat=\"%f\"\\,\ line\ %l:\ %m


This common linting utility for Javascript has a few output formats. The compact format outputs a structure similar to the following:

/some/dir/fullOfProblems.js: line 3, col 16, Error - Unexpected space before unary operator '++'. (space-unary-ops)
/some/dir/fullOfProblems.js: line 3, col 20, Warning - Missing semicolon. (semi)

This can be effectively parsed with this 'errorformat' setting:

set errorformat+=%f:\ line\ %l\\,\ col\ %c\\,\ %trror\ -\ %m
set errorformat+=%f:\ line\ %l\\,\ col\ %c\\,\ %tarning\ -\ %m


The mingw Windows port of the gcc c-compiler/linker from the FSF.

set errorformat+=%f:%l:\ %m

Modelsim vlog/vcom for Verilog/VHDL[]

A simulation tool for Verilog/VHDL. Error messages look like:
** Error: /pathto/somefile.v(115): near \"source text\": syntax error message.

set errorformat=**\ Error:\ %f(%l):\ %m

There are some other possible formats as well, including warning and note messages.

set errorformat=\*\*\ %tRROR:\ %f(%l):\ %m,\*\*\ %tRROR:\ %m,\*\*\ %tARNING:\ %m,\*\*\ %tOTE:\ %m,%tRROR:\ %f(%l):\ %m,%tARNING\[%*[0-9]\]:\ %f(%l):\ %m,%tRROR:\ %m,%tARNING\[%*[0-9]\]:\ %m


" CMake Parser
" Call stack entries
let &efm = ' %#%f:%l %#(%m)'
" Start of multi-line error
let &efm .= ',%E' . 'CMake Error at %f:%l (%m):'
" End of multi-line error
let &efm .= ',%Z' . 'Call Stack (most recent call first):'
" Continuation is message
let &efm .= ',%C' . ' %m'



Code for the Zilog eZ80 microprocessor can be built from Vim after installing ZDS. Create a makefile manually or use the one generated from a ZDS project.

With the following in your vimrc, you can use :Make to perform a :make and to open any resulting quickfix window:

command -nargs=* Make make <args>|cwindow 3

Add the following to file ~/.vim/after/ftplugin/c.vim (Unix) or $HOME/vimfiles/after/ftplugin/c.vim (Windows) – you may need to create the file. Then you can press F7 to build:

setlocal errorformat=%f\	(%l\\,%c)\ :\	ERROR\ (%n)\ %m
setlocal makeef=\myerrs.txt
nnoremap <F7> :update<CR>:Make -f myproject_myconf.mak<CR><CR>

The errorformat line contains two tab characters (shown as large whitespaces above).

Todo: Should investigate use of :let errorformat=... with \t to avoid need to use literal tab characters.


set efm=%E%f:%l.%c:,%E%f:%l:,%C,%C%p%*[0123456789^],%ZError:\ %m,%C%.%#

%E%f:%l.%c:   to parse "FILENAME:LINENUMBER.COLNUMBER:".
%E%f:%l:   to parse "FILENAME:LINENUMBER:".
%C:   to pass over the empty line.
%C%p%*[0123456789^]:   to get the column number from the indicator line (" 1").
%ZError:\ %m:   to parse the error message ("Error: ERROR_MESSAGE").
%C%.%#:   to pass over the source code line (and ignore it).

The above allows parsing of the following message (make output):

gfortran hello-world.f90 -o hello-world.exe

sprint *, "hello", pi, x, r
Error: Unclassifiable statement at (1)

r = cotan(pi/2)
Error: Function 'cotan' at (1) has no IMPLICIT type
make: *** [hello-world.exe] Error 1

In Vim, :clist then shows:

2 hello-world.f90:11 col 1 error:  Unclassifiable statement at (1)
3 hello-world.f90:9 col 4 error:  Function 'cotan' at (1) has no IMPLICIT type

Where hello-world.f90 is:

program hello
implicit none

real (kind = 10), dimension(10):: r
real (kind=8):: pi

pi = atan(1.0) * 4
r = cotan(pi/2)
sprint *, "hello", pi, x, r

end program

See also[]




  • Clean up tips in Category:Compiler.
  • Where appropriate, should merge compiler tips for a particular language into one tip.
  • Need emphasis to be on the :compiler command (don't directly mess with 'efm').
  • Settings for errorformat should be in a compiler plugin rather than in vimrc. :help write-compiler-plugin :help compiler-select
  • If there is no support for a compiler, user should add a new compiler (need example of how).
  • Need links to a tip with info on the quickfix window.

Related tips (all are in Compiler category; first four are in 'see also' above)

Many existing tips have obsolete/bad advice, for example, tip 476 says to edit the $VIM/ftplugin/perl.vim file (probably means $VIMRUNTIME/ftplugin/perl.vim but you should never patch a distribution file).