sponsor Vim development Vim logo Vim Book Ad

gotofile : gf replacement by using the tags file

 script karma  Rating -1/1, Downloaded by 587  Comments, bugs, improvements  Vim wiki

created by
Nathan Huizinga
 
script type
utility
 
description
This script defines a new command 'GotoFile', which resembles the normal
'gf' function, but uses a standard tags file generated by ctags for
looking up the file name under the cursor.

You need to generate a standard tags file (with ctags) for this script to work.
Add the following ctags option for generating filename tags: --extra=+f

For example: ctags -R --extra=+f

Add the following mapping to your .vimrc (or _vimrc) to replace the
normal 'gf' behavior by the GotoFile command:

nmap <silent> gf :GotoFile<CR>

I wrote this script mainly for having an alternative for setting the
path and using 'gf'. While using completion all header files within
the path are also searched, which causes a major performance hit for
large projects (at least for me). So this script allows using the
'gf' feature without setting the path. Other suggestions are welcome!
 
install details
Just place this script in your plugin directory.
Generate the tags file with ctags.
Make sure that your tags file can be found by vim. See :help 'tags'
Install the latest version of genutils (vimscript #197).

 

rate this script Life Changing Helpful Unfulfilling 
script versions (upload new version)

Click on the package to download.

package script version date Vim version user release notes
GotoFile.vim 0.1 2007-03-02 7.0 Nathan Huizinga Initial upload
ip used for rating: 3.17.203.68

If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to the maillist. Help Bram help Uganda.
   
Vim at Github