如何告诉Vim编辑器我的包含文件路径,以便在按CTRL+ 时它可以自动完成功能名称N?
例如,我有一个如下的C程序:
#include<stdio.h>
int main()
{
sca // here I press control+N, it does not complete to scanf
}
Run Code Online (Sandbox Code Playgroud)
Rob*_*lls 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)
Run Code Online (Sandbox Code Playgroud)
您也可以通过打开文件然后输入来检查路径
:checkpath
Run Code Online (Sandbox Code Playgroud)
这将为您提供缺少的所有包含文件的列表.注意它似乎没有处理预处理器指令,所以你会得到一些误报.进入
:checkpath!
Run Code Online (Sandbox Code Playgroud)
将提供已找到和缺失的包含文件的完整列表.
Ken*_*ric 15
此外,重要的是要注意有许多完成功能.
^x ^o = "omnicomplete"
^x ^i = "included-files completion"
^x ^f = "path completion"
^x ^l = "Complete this line using one that looks the same"
Run Code Online (Sandbox Code Playgroud)
看到
:help ins-completion
Run Code Online (Sandbox Code Playgroud)
更多.