2011-03-30 46 views
1

Vim的編譯器插件應該將變量current_compiler的值設置爲某個值。除非它們用於擴充現有的編譯器插件,否則它們還應該提前退出,如果該變量已經定義的話。是否打算使用該變量的值?它應該設置爲編譯器插件文件的基本名稱嗎? (例如$VIMRUNTIME/compiler/foo.vim - >foo`current_compiler`變量的值的意義

documentation有這樣說:

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}

writing compiler plugins上的條目沒有提供附加信息,上述條目涵蓋了vim幫助數據庫中的所有字符串current_compiler(根據:lhelpgrep current_compiler)的實例。

回答

0

您可以在~.vim/after/ftplugin/<filetype>.vim中預先選擇文件類型的特定編譯器。 因爲無論何時加載緩衝區(例如,當通過:args時),都會重新編譯它,所以建議只在編譯器尚未設置(即僅在第一次加載時)時才設置它。否則,切換緩衝區可能會覆蓋任何已更改的編譯器,並且設置編譯器時的消息可能始終打印(並需要進行確認)。