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

前端之家收集整理的这篇文章主要介绍了编译 – 在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

  1. " Vim compiler file
  2. " Compiler: GNU C Compiler
  3. " Maintainer: Nikolai Weibull <now@bitwi.se>
  4. " Latest Revision: 2006-12-20
  5.  
  6. if exists("current_compiler")
  7. finish
  8. endif
  9. let current_compiler = "gcc"
  10.  
  11. let s:cpo_save = &cpo
  12. set cpo-=C
  13.  
  14. CompilerSet errorformat=
  15. \%*[^\"]\"%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
  16.  
  17. if exists('g:compiler_gcc_ignore_unmatched_lines')
  18. CompilerSet errorformat+=%-G%.%#
  19. endif
  20.  
  21. let &cpo = s:cpo_save
  22. unlet s:cpo_save

猜你在找的Bash相关文章