You are not logged in.

#1 2005-11-25 16:04:02

Komodo
Member
From: Oxford, UK
Registered: 2005-11-03
Posts: 674

inside-vim code compilation

So at the moment I've got this in my vimrc

" C Options
"set makeprg=gcc -o %< %

" Java Options
set makeprg=javac %
set errorformat=%A%f:%l: %m,%-Z%p^,%-C%.%#

" PHP Options
"set makeprg=php -l %
"set errorformat=%m in %f on line %l 

and I uncomment and recomment to get the compiler and error format correct depending on the language I'm using.

Can someone show me how to do an automatic syntax test on the file I'm currently editing so that vim will select the correct compiler itself?


.oO Komodo Dave Oo.

Offline

#2 2005-12-04 20:33:13

dimi
Member
Registered: 2005-12-04
Posts: 15

Re: inside-vim code compilation

You could try it like this:

au FileType ada set makeprg=gnatmake %
au FileType java set makeprg=javac %
au FileType c set makeprg=gcc -o %< %

etc.

Offline

#3 2005-12-04 21:12:57

elasticdog
Member
From: Washington, USA
Registered: 2005-05-02
Posts: 995
Website

Re: inside-vim code compilation

That should work, but it would be better to use <code>setlocal</code> instead of just <code>set</code> so it will only change the editor settings for the one particular file you're working on...otherwise it will adjust the global options, which can be confusing if you're working on multiple file types at once.

Offline

#4 2005-12-04 21:17:18

phrakture
Arch Overlord
From: behind you
Registered: 2003-10-29
Posts: 7,879
Website

Re: inside-vim code compilation

I would probably be best to use ~/.vim/ftplugins/*
add the java stuff to "java.vim" in that dir, c=c.vim, ada=ada.vim.

Offline

#5 2005-12-05 00:27:35

elasticdog
Member
From: Washington, USA
Registered: 2005-05-02
Posts: 995
Website

Re: inside-vim code compilation

Hot diggity phrakture!  I know who I'm coming to next time I have vim problems...I think you've answered about the last 15 that have come up  big_smile

Offline

#6 2005-12-08 00:01:35

Komodo
Member
From: Oxford, UK
Registered: 2005-11-03
Posts: 674

Re: inside-vim code compilation

great info guys, thanks a lot! big_smile


.oO Komodo Dave Oo.

Offline

Board footer

Powered by FluxBB