Reputation: 55
I find Vim's keyword completion very useful when I only have files of the same filetype open. But as soon as I start editing more than one filetype, it becomes much less useful. If I'm editing a Python project and then open my vimrc in another tab, keyword completion from inside a Python file will now include keywords from my vimrc. Without disabling the options for complete to look in other buffers, is it possible to have keyword completion work only with buffers of the same filetype?
Upvotes: 1
Views: 276
Reputation: 172590
Good idea. I'm a huge fan of the Vim insert-mode completion, and have written a library that makes it easy to implement custom completions: CompleteHelper.
With a little enhancement to that library (which I've just implemented in version 1.30), it allows to limit the completion candidates to certain buffers. With this, I've implemented your suggestion as the SameFiletypeComplete plugin. Try it out; I hope it's useful to you.
Upvotes: 1
Reputation: 196566
You are using <C-n>
/<C-p>
, right?
The value of set complete
determines the completion sources. The default value includes the content of other buffers and windows in the completion list.
See :help 'complete'
for a list of options. This will probably solve your problem:
:set complete=.,t,i
Alternatively, you could use other completion shortcuts like <C-x><C-n>
, <C-x><C-p>
or <C-x><C-o>
, depending on what you want to complete. See :help ins-completion
.
Upvotes: 1