tags:

views:

339

answers:

4

One of my favorite vim features is the ability to do

set path=/my/project/root/**

and then use

:find SomeClassFile.java

Only problem is, I've got some generated directories at that level that I cannot move and wish to exclude from such searches. I can't seem to figure out how to exclude those dirs. Anyone know how/if this can be done?

+1  A: 

I'm pretty sure you can't exclude things from a "**" search. Instead, you could specify all the subdirectories below that one that don't include generated code, like

set path=/my/project/root/src/**,/my/project/root/com/**,/my/project/root/foo/**
Paul Tomblin
Unfortunately, this is what I ended up doing.
davetron5000
A: 

I don't know of a way using vim syntax, but you could create yourself a .vimrc.proj file (my naming convention) and fill it with whatever you want that pertains to that project, then 'source' it.

So, you would have the following in /my/project/root/.vimrc.proj (using Paul Tomblin's example):

set path=/my/project/root/src/**,/my/project/root/com/**,/my/project/root/foo/**

And then from within vim:

:source /my/project/root/.vimrc.proj

Basically, once you have the file set up it would be a similar number of keystrokes to set the project path. Of course, you can also place other project specific settings in there as well such as cscope mappings or whatever.

Admittedly, it leaves a 'dropping' in the file system but plenty of other environments create project files.

shank
A: 

It should be taken care of by the &wildignore option. However, AFAIK, it doesn't. I did emit a bug report on this topic, but I haven't seen any patch since then.

By the mean time, I've developed a globpath-like function that ignores paths containing undesired patterns (like /CVS/ e.g.), and I use this function in my find-like commands.

Luc Hermitte
A: 

If you're on a unix-like system, you can use backticks to run a command-line script like this:

:e `find . -name foo.java -print`

So you could write your own script to exclude whatever directories you want. I've done a similar thing to exclude .svn directories from :grep.

See :h backtick-expansion in vim for more information.

Kristo