errorformat in Vim

Vim can parse compilation errors when it is passed as an error file using the argument -q. It can also parse the errors produced by running :make. In both these cases, the file path, line and column number of errors can be parsed and traversed using :cnext or displayed in the QuickFix window.

The errorformat is the list of error formats that Vim uses to parse and recognize errors from input text. The default error format in Vim can be seen by trying the command :set errorformat?. The items in the list of error formats are separated by a comma. When separated, these are the components of the list:

%*[^"]"%f"%*\D%l: %m
"%f"%*\D%l: %m
%-G%f:%l: (Each undeclared identifier is reported only once
%-G%f:%l: for each function it appears in.)
%-GIn file included from %f:%l:%c:
%-GIn file included from %f:%l:%c\,
%-GIn file included from %f:%l:%c
%-GIn file included from %f:%l
%-G%*[ ]from %f:%l:%c
%-G%*[ ]from %f:%l:
%-G%*[ ]from %f:%l\,
%-G%*[ ]from %f:%l
"%f"\, line %l%*\D%c%*[^ ] %m
%D%*\a[%*\d]: Entering directory `%f'
%X%*\a[%*\d]: Leaving directory `%f'
%D%*\a: Entering directory `%f'
%X%*\a: Leaving directory `%f'
%DMaking %*\a in %f
%f|%l| %m

This default error format is set in Vim as DFLT_EFM based on the platform as seen in the source code here. Other error formats can be set at runtime based on the compiler flag. The different options for compiler and their corresponding error formats can be seen listed in the files in the directory /usr/share/vim/vim74/compiler. In fact, the default error format string set on Linux is the same as that in /usr/share/vim/vim74/compiler/gcc.vim

For more on error format see :help errorformat in Vim.

Tried with: Vim 7.4 and Ubuntu 14.04

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.