简体   繁体   中英

Why does gf does not work for vim but ctrl+] works?

I have a file eg a.pl that has this method call:

add_location(@crew);

The actual definition is in the same file. If I do: CTRL + ] the cursor jumps to the definition. If I do: gf I get:
E447: Can't find file "add_location" in path

If I do :pwd I get the current working directory. What path is the complaint about? The function definition is in the same file.

The <C-]> command goes to the tag under the cursor; you seem to have a valid tags database (ie have run ctags before) and there is a tag named add_location .

The gf command goes to the file under the cursor, ie it treats add_location as a filename (possibly appending a suffix like .pl (see :help 'suffixesadd' ), and searches for that in the directories specified by 'path' .

So, basically, you're using the wrong command for the job; <C-]> is right. Note that if the location is in the same file, you could also use the * command to go to next matches; this is useful for when you have no tags database and therefore cannot use the more powerful <C-]> command.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM