2008-11-21 76 views
11

如何告訴Vim編輯器關於我的包含文件路徑,以便當我按CTRL + N它可以自動完成函數名稱?Vim關鍵字完成

例如,我有一個像下面的C程序:

#include<stdio.h> 
int main() 
{ 
    sca // here I press control+N, it does not complete to scanf 
} 
+0

我在使用vim視窗 – chappar 2008-11-21 09:41:08

回答

19

在你.vimrc,路徑添加到您的.vimrc

set path+=/usr/include/** 
set path+=/my_include_dir/include 
set path+=/my_include_dir/srclib/apr/** 
set path+=/my_other_include_dir/srclib/apr-util/** 

** means all sub-directories. 
* means all contained directories 
. means all files in the directory of the found file 
+= means prepend to existing path (iirc) 

可以檢查的路徑,以及通過打開文件然後輸入

:checkpath 

這會給你一個列表會包含缺少的文件。注:它似乎不處理預處理器指令,所以你會得到一些誤報。輸入

:checkpath! 

將提供找到和丟失的包含文件的完整列表。

16

此外,重要的是要注意有很多完成功能。

^x ^o = "omnicomplete" 
^x ^i = "included-files completion" 
^x ^f = "path completion" 
^x ^l = "Complete this line using one that looks the same" 

看到

:help ins-completion 

更多。

3

如果文件位於標準位置,Vim可能也會知道路徑。 < C-n >使用'完整'選項和標記i掃描包含文件。要添加i爲「完成」:

set complete+=i

你也可以得到你想要完成的符號,你可以使用一個標籤文件:

set complete+=t