created 2005 · complexity basic · author Reva Revadigar · version 6.0
Often, you work in a huge code base containing a lot of directories and source files (C++, C#, etc) and you want to quickly edit a file. If you know at least some part of the file name, you can use this tip to look up the file and edit it.
You need some Unix tools such as find, cat, sed and sort. GNU Windows versions of these will do as well.
Put the following in a batch file (these examples are for Windows; you can do equivalents for Unix):
@find [directory] > c:\files.txt @cat c:\files.txt | sed -f c:\tags.sed | sort > c:\files.tags
Replace [directory] with whatever directory you want to find the files in. For example, c:\root.
Here, c:\tags.sed contains the following:
s/\\/\//g s/\(.*\/\)\(.*\)/\2 \1\2 1;" F/g s/ //g /.*RECYC.*/d
Once, this is done, you simply do the following in your vimrc:
That's it! You can now look up and edit any file.
Example: If you have c:\root\Foo.cpp and c:\root\FooBar.cpp and you gave c:\root to find tool above, then doing
:tj Foo<tab> will give you completion for Foo.cpp and FooBar.cpp.
Comments[edit | edit source]
ctags does the same:
ctags -R --file-tags=yes c:/
See also script#1581.