Vim 'current_compiler'变量值的重要性

Vim 'current_compiler'变量值的重要性,vim,Vim,Vim的编译器插件应该设置变量current\u compiler的值。如果已经定义了某个变量,那么它们也应该提前退出,除非它们打算扩充现有的编译器插件。是否要使用变量的值?是否应将其设置为编译器插件文件的basename?(例如$VIMRUNTIME/compiler/foo.vim->foo) 政府这样说: To support older Vim versions, the plugins always use "current_compiler" and not "b:current_c

Vim的编译器插件应该设置变量
current\u compiler
的值。如果已经定义了某个变量,那么它们也应该提前退出,除非它们打算扩充现有的编译器插件。是否要使用变量的值?是否应将其设置为编译器插件文件的basename?(例如
$VIMRUNTIME/compiler/foo.vim
->
foo

政府这样说:

To support older Vim versions, the plugins always use "current_compiler" and
not "b:current_compiler".  What the command actually does is the following:

- Delete the "current_compiler" and "b:current_compiler" variables.
- Define the "CompilerSet" user command.  With "!" it does ":set", without "!"
  it does ":setlocal".
- Execute ":runtime! compiler/{name}.vim".  The plugins are expected to set
  options with "CompilerSet" and set the "current_compiler" variable to the
  name of the compiler.
- Delete the "CompilerSet" user command.
- Set "b:current_compiler" to the value of "current_compiler".
- Without "!" the old value of "current_compiler" is restored.
引用的命令是
:compiler
。它的参数成为上面使用的
{name}


上的条目不提供额外信息,上述条目涵盖vim帮助数据库中字符串
当前编译器的所有实例(根据
:lhelpgrep当前编译器
)。

您可以在
~.vim/after/ftplugin/.vim>中为文件类型预先选择特定的编译器。
因为每当加载缓冲区时(例如,当通过:args移动时),都会重新获取资源,因此建议仅在尚未设置编译器时(即仅在第一次加载时)才设置编译器。否则,切换缓冲区可能会覆盖任何更改的编译器,并且设置编译器时的消息可能会一直打印(并且需要确认)