Vim Tips Wiki
Explore
Main Page
All Pages
Community
Interactive Maps
Community portal
To do
FANDOM
Fan Central
BETA
Games
Anime
Movies
TV
Video
Wikis
Explore Wikis
Community Central
Start a Wiki
Don't have an account?
Register
Sign In
Sign In
Register
Vim Tips Wiki
1,649
pages
Explore
Main Page
All Pages
Community
Interactive Maps
Community portal
To do
Editing
Errorformats
Back to page
Edit
Edit source
View history
Talk (0)
Edit Page
Errorformats
We recommend that you
log in
before editing. This will allow other users to leave you a message about your edit, and will let you track edits via your
Watchlist
.
Creating an account
is quick and free.
The edit appears to have already been undone.
Anti-spam check. Do
not
fill this in!
__TOC__ {{Duplicate|518|682}} {{TipNew |id=1575 |previous=1574 |next=1576 |created=2008 |complexity=basic |author=Bmearns |version=7.0 |subpage=/200806 |category1=Compiler |category2= }} 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 == [https://man7.org/linux/man-pages/man3/assert.3.html 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%*[\,:]' where 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. ==flex== The free alternative to LEX, a lexical parser generator. Error messages are like: ''"somefile.l", line 15: rule cannot be matched''. <pre> set errorformat+=%*[\"]%f%*[\"]\\,\ line\ %l:\ %m </pre>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 ==bison== 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. <pre> set errorformat+=%f:%l.%c-%*[0-9]:\ %m set errorformat+=%f:%l.%c:\ %m set errorformat+=%f:\ %m </pre> ==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''. <pre> set errorformat=\"%f\"\\,\ line\ %l:\ %m </pre> == eslint == This common linting utility for Javascript has a few output formats. The '''compact''' format outputs a structure similar to the following: <pre> /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) </pre> This can be effectively parsed with this 'errorformat' setting: <pre> set errorformat+=%f:\ line\ %l\\,\ col\ %c\\,\ %trror\ -\ %m set errorformat+=%f:\ line\ %l\\,\ col\ %c\\,\ %tarning\ -\ %m </pre> == mingw == The mingw Windows port of the gcc c-compiler/linker from the FSF. <pre> set errorformat+=%f:%l:\ %m </pre> ==Modelsim vlog/vcom for Verilog/VHDL == A simulation tool for Verilog/VHDL. Error messages look like:<br>''** Error: /pathto/somefile.v(115): near \"source text\": syntax error message.'' <pre> set errorformat=**\ Error:\ %f(%l):\ %m </pre> There are some other possible formats as well, including warning and note messages. <pre> 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 </pre> ==CMake== <pre> " 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' </pre> ==Historical== ===Zilog=== Code for the [[wikipedia:Zilog eZ80|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 <code>:Make</code> to perform a <code>:make</code> and to open any resulting quickfix window: <pre> command -nargs=* Make make <args>|cwindow 3 </pre> Add the following to file <code>~/.vim/after/ftplugin/c.vim</code> (Unix) or <code>$HOME/vimfiles/after/ftplugin/c.vim</code> (Windows) β you may need to create the file. Then you can press F7 to build: <pre> setlocal errorformat=%f\ (%l\\,%c)\ :\ ERROR\ (%n)\ %m setlocal makeef=\myerrs.txt nnoremap <F7> :update<CR>:Make -f myproject_myconf.mak<CR><CR> </pre> The errorformat line contains two tab characters (shown as large whitespaces above). :''Todo'': Should investigate use of <code>:let errorformat=...</code> with <code>\t</code> to avoid need to use literal tab characters. ===gfortran=== <pre> set efm=%E%f:%l.%c:,%E%f:%l:,%C,%C%p%*[0123456789^],%ZError:\ %m,%C%.%# </pre> <poem> <code>%E%f:%l.%c:</code> to parse "FILENAME:LINENUMBER.COLNUMBER:". <code>%E%f:%l:</code> to parse "FILENAME:LINENUMBER:". <code>%C:</code> to pass over the empty line. <code>%C%p%*[0123456789^]:</code> to get the column number from the indicator line (" 1"). <code>%ZError:\ %m:</code> to parse the error message ("Error: ERROR_MESSAGE"). <code>%C%.%#:</code> to pass over the source code line (and ignore it). </poem> The above allows parsing of the following message (make output): <pre> gfortran hello-world.f90 -o hello-world.exe hello-world.f90:11: sprint *, "hello", pi, x, r 1 Error: Unclassifiable statement at (1) hello-world.f90:9.4: r = cotan(pi/2) 1 Error: Function 'cotan' at (1) has no IMPLICIT type make: *** [hello-world.exe] Error 1 </pre> In Vim, <code>:clist</code> then shows: <pre> 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 </pre> Where hello-world.f90 is: <pre> 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 </pre> ==See also== *[[VimTip518|Errorformat for icc7]] *[[VimTip682|Errorformat for Intel ifort]] *[[VimTip325|Errorformat for java/ant/junit/cygwin/bash]] *[[VimTip476|Errorformat and makeprg]] ==References== *{{help|'errorformat'}} *{{help|'makeef'}} ==Comments== {{Todo}} *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 <code>:compiler</code> command (don't directly mess with <code>'efm'</code>). *Settings for <code>errorformat</code> 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) *[[VimTip476|476 Errorformat and makeprg]] *[[VimTip325|325 Errorformat for java/ant/junit/cygwin/bash]] *[[VimTip518|518 Errorformat for icc7]] *[[VimTip682|682 Errorformat for Intel ifort]] *[[VimTip1107|1107 J2ME development]] *[[VimTip3|3 Compile Java with Jikes]] *[[VimTip120|120 Compile Java with Sun JDK javac]] *[[VimTip385|385 Some Java tips]] *[[VimTip458|458 Use the quickfix window to list all errors]] *[[VimTip280|280 Integration with PyUnit testing framework]] *[[VimTip949|949 Integrate Pylint and Pychecker support]] *[[VimTip473|473 Compiler for perl]] *[[VimTip692|692 Runtime syntax check for php]] *[[VimTip443|443 A better interfacing of (La)TeX with the quickfix mode]] *[[VimTip852|852 Make support for NEC V850 CA850 compilers]] Many existing tips have obsolete/bad advice, for example, tip 476 says to edit the <code>$VIM/ftplugin/perl.vim</code> file (probably means <code>$VIMRUNTIME/ftplugin/perl.vim</code> but you should never patch a distribution file). ----
Summary:
Please note that all contributions to the Vim Tips Wiki are considered to be released under the CC-BY-SA
Cancel
Editing help
(opens in new window)
Templates used on this page:
Template:Duplicate
(
view source
)
Template:Help
(
view source
)
Template:Navigation
(
view source
)
Template:TipNew
(
view source
)
Template:Todo
(
view source
)
Follow on IG
TikTok
Join Fan Lab