gpt4 book ai didi

compilation - :compiler command do in Vim? 是什么意思

转载 作者:行者123 更新时间:2023-12-03 11:00:42 29 4
gpt4 key购买 nike

最近发现Vim中有一个命令叫compiler。您可以使用任何常见的编译器(例如,:compiler gcc、:compiler php 等)来调用它,但它似乎没有任何立竿见影的效果。

我在联机帮助页上进行了搜索,但没有找到任何关于它实际作用的有用信息,Vim Wiki 也没有。有谁知道该命令实际上是做什么的?

最佳答案

它为该编译器设置选项,例如用于 :make 的程序以及错误消息的格式,以便 vim 可以将您跳转到错误位置。查看 $VIMRUNTIME/compiler/对于可以获取的不同 .vim 文件。
:help write-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

关于compilation - :compiler command do in Vim? 是什么意思,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3031009/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com