Vim Tips Wiki
Advertisement

Previous TipNext Tip

Tip: #476 - Errorformat and makeprg

Created: May 20, 2003 9:39 Complexity: basic Author: sputnik Version: 5.7 Karma: 14/5 Imported from: Tip#476

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 VimTip203

Ah! I mapped F-5 to :Make, and made it go back to the main window:

map <F5> :Make<cr><C-w><Up>

Comments

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)

brett williams at agilent dot com , May 20, 2003 12:13


Advertisement