sponsor Vim development Vim logo Vim Book Ad

basic Tip #476: multime errorformat & makeprgs

 tip karma   Rating 6/3, Viewed by 794 

created:   May 20, 2003 9:39      complexity:   basic
author:   sputnik      as of Vim:   5.7

I was fiddling around with the errorformat and makeprg opts, and as I code in different languages, i was wondering if there was a way of specifiing a special makeprg and errorformat parameter for each language.... and THERE IS!!

just edit the $VIM/ftplugin/[syntaxfile].vim

i.e.: perl.vim
added at the end :
set makeprg=$HOME/bin/vimparse.pl\ -c\ %\ $*
set errorformat=%f:%l:%m

c.vim
set makeprg=g++\ %

well, and you get the pattern.

It works delightfully with the :Make tip vimtip #203

Ah! I mapped F-5 to :Make, and made it go back to the main window:
map <F5> :Make<cr><C-w><Up>

 rate this tip  Life Changing Helpful Unfulfilling 

<<wrap visual selection with fold markers | How to put the indentation level on the status line >>

Additional Notes

brett williams at agilent dot com, May 20, 2003 12:13
I prefer to make a compiler plugin, then use a ftplugin to set a default compiler, i.e.:

~/.vim/compiler/xmllint.vim:
if exists("current_compiler")
  finish
endif
let current_compiler = "xmllint"
setlocal makeprg=xmllint\ --valid\ --noout\ %
setlocal errorformat=%f:%l:\ %m

~/.vim/ftplugin/xml.vim
compiler xmllint


This way you can actually set up as many compilers as you want for the same filetype.  I set a default in my ftplugin, but then a quick ':compiler somecompiler' will change to a different one as opposed to having to set makeprg and errorformat (remembering those is non-trivial)
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to [email protected] after searching the archive. Help Bram help Uganda.
Sponsored by Web Concept Group Inc. SourceForge Logo