"atstake atstake" <[EMAIL PROTECTED]> 写于 2006-11-27 09:37:40: > I'm using vim 6.4.7 on Fedora Core 5. I would like to compile C, > Perl, ruby & bash script from within vim. I want vim to recognize a file > by extenstion and if I map it to, say, <F3> vim would be able to compile > the code based on the extension; eg. if it's a .pl file it would do > "perl filename", show the result and if there's any error it would take > me to the line where the error is. > > Is there any easy way to do this with functions? Any example would be > greatly appreciated. > > Thanks.
The feature is already supported by Vim, and I bet that's the Vim native way to do that. See: :h :make_makeprg If you would like to know how this works, See also: $VIMRUNTIME/compiler/*.vim For example: $VIMRUNTIME/compiler/perl.vim In gerneral, each language has a "compiler script" describing which external compiler to use to compile the file and has the regexp patterns to parse the error message. If a file does not has compiler script by default or if you want to override something, you can write you own one in your ~/.vim/compiler/ After all, all you need to do is to :make, it will find the right compiler for current language and compile, and parse the output, move to the line of first error. And if you want <F3>, just do the following: :map <F3> :w<CR>:make<CR> -- Sincerely, Pan, Shi Zhu. ext: 2606
