I'm brushing up on my vim skills and fiddling with completion using the Ctrl-n command. I'm programming in Perl. When I am in insert mode and hit Ctrl-n, I get a message that it is Scanning included file down at the bottom of the terminal and it looks like it's scanning files in the perl distribution directories. This can take several seconds before it finishes. It looks like it does this with packages I include that are commented out:#use Moose;So I have to delete these lines for this feature to be of any value. Am I missing something?I am using the perl-support plugin.
Ctrl-n completion takes a long time for scanning included file
autocompletion
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 windowsb   scan other loaded buffers that are in the buffer listu   scan the unloaded buffers that are in the buffer listU   scan the buffers that are not in the buffer listk   scan the files given with the 'dictionary' optionkspell  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~/spanishs   scan the files given with the 'thesaurus' options{tsr}  scan the file {tsr}.  Several s flags can be given, patterns are valid too.i   scan current and included filesd   scan current and included files for defined name or macro |i_CTRL-X_CTRL-D|]   tag completiont   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 filesIf 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-=iIf 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-=iaugroup ENDOr better, you could create a filetype plugin, for example in ~/.vim/after/ftplugin/perl.vim, in which you would simply write:setlocal complete-=iTo 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.