3

I use gf to open "filename.h" from line like:

#include "filename.h"

in some C\C++ file.

Sometimes there is more than one "filename.h" that gf command can find in path. But gf gets me to the first file it finds - sometimes that's not what I want.

Is there a way to open the next file matching that name?

1 Answers1

3

From :h gf:

                                                       gf E446 E447
[count]gf               Edit the file whose name is under or after the cursor.
 ...
                        If a [count] is given, the count'th file that is found
                        in the 'path' is edited.

So you can do 2gf.

To browse the list of matches is trickier. The only way I found was to use use :find and Vim's command-line tab completion:

:find <cfile>Tab

Vim will cycle through matches and <cfile>:

enter image description here

muru
  • 24,838
  • 8
  • 82
  • 143