Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vim: Simple "jump to file" command?

Tags:

vim

What's the simplest way to "jump to a file somewhere in my source tree by name"? For example, if I'm working with "libfoo" that contains libfoo/foo/foo.py, I'd like to be able to jump to foo.py from anywhere within libfoo/**[0].

Possibly some way to do this with a tags file?

[0]: that is, libfoo/ and its subdirectories.

like image 970
David Wolever Avatar asked Aug 12 '10 01:08

David Wolever


People also ask

How do you go to a file in Vim?

Go to file Alternatively, you can visually select the file name, then type gf in which case Vim will use the selected text. When writing a program, it is helpful to set the 'path' option to list the directories with your include files. Then you can easily open an include file.

How do I change the path of a file in Vim?

Add file directory to Vim path This can be modified using :set path^= instead of :set path+= , which prepends the new directory to the beginning of the path instead of appending it to the end. For this to work, you will need to remove the path being added first, because otherwise the path^= will take no action.


2 Answers

Add ** is to you comma-separated vim path variable (not system path) and if you're in some parent dir of the project use:

:find foo.py
like image 136
Ry4an Brase Avatar answered Sep 28 '22 10:09

Ry4an Brase


check out command-t, FuzzyFinder, or FuzzyFinder_Textmate

Personally, I find command-t has the best UI, but FuF_Textmate is best for quickly getting to the right place in very large projects (which is why I use it after trying all 3)

Note that fuzzyfinder_textmate is unmaintained by its origional author, so you may have to poke around the gh network tab to find who has the most up to date branch. also note it is a bit of a pain to install.

like image 36
Matt Briggs Avatar answered Sep 28 '22 11:09

Matt Briggs