Vim logo vim online Vim Book Ad

basic Tip #255: arbitrary tags for file names

 tip karma   Rating 4/1, Viewed by 477 

created:   June 4, 2002 22:24      complexity:   basic
author:   Travis      as of Vim:   5.7

This definitely work on linux and there is probably some windows equivalent.
I've started working with tomcat and many many .jsp files.  I find this trick to be very helpful.

find -name '*.jsp' -printf '%f\t%P\t1\n' |sort > jsp.tags

This will create a file called jsp.tags with tag entries for each .jsp file.  Within Vim I use

:set tags+=jsp.tags

Now I can to simple :tag file.jsp to quickly switch b/w the many, many .jsp files.

One important note.  The utility sort will use the value of LC_COLLATE to sort according to your
locale.  This will give Vim issues.  So try "LC_COLLATE=C sort" instead of plain "sort"

 rate this tip  Life Changing Helpful Unfulfilling 

<<Using \%[] to easily match parts of a word. | Opening current Vim file in your Windows browser >>

Additional Notes

Mark Hillebrand, June 4, 2002 23:10
There's also the :find command and the path-option, with which one can easily switch between files in arbitrary directories.

For example, if one sets
  :set path+=/usr/include
on a Unix system one can do ":find stdio.h" to jump to the stdio-header file.

Recursive search is also possible by using the double-star:
  :set path+=./**
Vim will :find any file under the current sub directory.

Use :sfind (split find) to open the file in a new window.
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 [email protected] after searching the archive. Help Bram help Uganda.
SourceForge Logo