By default, when you hit C-n
or C-p
, Vim looks inside various sources to find candidates which will populate the completion menu.
These sources can be configured with the buffer-local 'complete'
option.
The value of this option is a comma-separated list of flags. Each flag has its own meaning described in :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 "]"
By default, its value is .,w,b,u,t,i
, which means:
1. the current buffer
2. buffers in other windows
3. other loaded buffers
4. unloaded buffers
5. tags
6. included files
If you find that scanning the included files takes too much time, you could try to remove the i
flag from the 'cpt'
option.
If you wanted to remove it from the global value, to affect all the buffers by default, you would write in your vimrc
:
setglobal complete-=i
If you wanted to do the same thing, but only for perl
files, you could install an autocmd inside your vimrc
:
augroup PerlSettings
autocmd!
autocmd FileType perl setlocal complete-=i
augroup END
Or better, you could create a filetype plugin, for example in ~/.vim/after/ftplugin/perl.vim
, in which you would simply write:
setlocal complete-=i
To check out what's the current global and local values of your 'complete'
option, and where they were last set, you could use these commands:
verbose setglobal complete?
verbose setlocal complete?
Or shorter:
verb setg cpt?
verb setl cpt?
If the only source in which you're interested is the current buffer, then, instead of using C-n
, you could use C-x C-n
. See :h i_^x^n
for more info.
let g:ctrlp_custom_ignore = { 'dir': '^/usr/' } let g:ctrln_custom_ignore = { 'dir': '^/usr/' }