1

I often use VIM auto-complete (CTRL+N\P) facility, it recognizes enums or defines (string based I guess) that are only in the set of current open files. In order to overcome this, I usually open a header file that contain all the enums\defines in a new tab, and then the auto-complete has all the values.

I wonder if there were a way to include this file in the default set of files that vim looks in when it searches for the auto-complete.

Thanks.

2 Answers 2

6

With the default value of the complete option, <C-n> and <C-p> should complete using your include files. You may wish to adjust the path option, though (see :help 'path').

You can also use the following command to tell Vim to use /path/to/file as a dictionary completion source:

:set complete+=k/path/to/file

See :help 'complete'.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks romainl, that was exactly what I needed. Nadav.
1

Also consider the 'include' option. Assuming that 'complete' includes the i flag (which is part of the default), vim will automatically search included files. The default value of 'include' recognizes C-style include statements:

#include "foo.h"

If you are editing some other language, then you may want to choose a different setting, probably in an ftplugin file.

:help 'complete'
:help 'include'
:help 'path'

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.