微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

编译 – 在Vim中编译器命令是做什么的?

我最近发现在Vim中有一个命令称为编译器。您可以使用任何常见的编译器(例如:编译器gcc,编译器PHP等)调用它,但它似乎没有任何立即的效果

搜索的是联机帮助页,但没有发现任何有用的东西,它实际上做什么,Vim维基也没有。有没有人知道该命令实际上是做什么的?

它为该编译器设置选项,例如用于:make和错误消息的格式的程序,以便vim可以将您转到错误位置。查看$ VIMRUNTIME /编译器/可以提供不同的.vim文件

:help-compiler-plugin

A compiler plugin sets options for use with a specific compiler. The user can
load it with the :compiler command. The main use is to set the
‘errorformat’ and ‘makeprg’ options.

另请参见:help errorformat和:help makeprg。

这是我机器上的GCC编译器文件,例如:

/usr/share/vim/vim72/compiler/gcc.vim

" Vim compiler file
" Compiler:         GNU C Compiler
" Maintainer:       nikolai Weibull <Now@bitwi.se>
" Latest Revision:  2006-12-20

if exists("current_compiler")
  finish
endif
let current_compiler = "gcc"

let s:cpo_save = &cpo
set cpo-=C

CompilerSet errorformat=
      \%*[^\"]\"%f\"%*\\D%l:\ %m,\\"%f\"%*\\D%l:\ %m,\%-G%f:%l:\ %trror:\ (Each\ undeclared\ identifier\ is\ reported\ only\ once,\%-G%f:%l:\ %trror:\ for\ each\ function\ it\ appears\ in.),\%f:%l:\ %m,\\"%f\"\\,\ line\ %l%*\\D%c%*[^\ ]\ %m,\%D%*\\a[%*\\d]:\ Entering\ directory\ `%f',\%X%*\\a[%*\\d]:\ Leaving\ directory\ `%f',\%D%*\\a:\ Entering\ directory\ `%f',\%X%*\\a:\ Leaving\ directory\ `%f',\%DMaking\ %*\\a\ in\ %f

if exists('g:compiler_gcc_ignore_unmatched_lines')
  CompilerSet errorformat+=%-G%.%#
endif

let &cpo = s:cpo_save
unlet s:cpo_save

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐