Answers:
默认情况下,当您按下C-n
或时C-p
,Vim会在各种来源内查找以找到将填充完成菜单的候选对象。
可以使用buffer-local 'complete'
选项配置这些源。
此选项的值是一个用逗号分隔的标志列表。每个标志都有其自身的含义,如:h 'cpt
:
. scan the current buffer ('wrapscan' is ignored)
w scan buffers from other windows
b scan other loaded buffers that are in the buffer list
u scan the unloaded buffers that are in the buffer list
U scan the buffers that are not in the buffer list
k scan the files given with the 'dictionary' option
kspell use the currently active spell checking |spell|
k{dict} scan the file {dict}. Several "k" flags can be given, patterns are valid too. For example:
:set cpt=k/usr/dict/*,k~/spanish
s scan the files given with the 'thesaurus' option
s{tsr} scan the file {tsr}. Several "s" flags can be given, patterns are valid too.
i scan current and included files
d scan current and included files for defined name or macro |i_CTRL-X_CTRL-D|
] tag completion
t same as "]"
默认情况下,其值为.,w,b,u,t,i
,表示:
1. the current buffer
2. buffers in other windows
3. other loaded buffers
4. unloaded buffers
5. tags
6. included files
如果发现扫描包含的文件花费太多时间,则可以尝试i
从该'cpt'
选项中删除该标志。
如果要从全局值中删除它,以默认情况下影响所有缓冲区,则可以这样写vimrc
:
setglobal complete-=i
如果您想做同样的事情,但只针对perl
文件,可以在其中安装一个autocmd vimrc
:
augroup PerlSettings
autocmd!
autocmd FileType perl setlocal complete-=i
augroup END
或者更好的是,您可以创建一个文件类型插件,例如在~/.vim/after/ftplugin/perl.vim
中,您只需编写以下内容:
setlocal complete-=i
要查看您的'complete'
选项的当前全局值和局部值以及它们的最后设置位置,可以使用以下命令:
verbose setglobal complete?
verbose setlocal complete?
或更短:
verb setg cpt?
verb setl cpt?
如果您感兴趣的唯一来源是当前缓冲区,则C-n
可以使用代替使用C-x C-n
。请参阅:h i_^x^n
以获取更多信息。
'complete'
提到了“包含的文件”,但是没有链接到这意味着什么的更多细节。因此,请阅读:he include-search
。在那里,您可以看到该'include'
选项定义了含义,并'path'
用于搜索。与仅打开/关闭整个功能相比,这些功能可用于进行更好的自定义。
let g:ctrlp_custom_ignore = { 'dir': '^/usr/' } let g:ctrln_custom_ignore = { 'dir': '^/usr/' }