On Tue, 9 May 2006, Gerald Lai wrote:

[snip]
Don't call me picky ... but there's the problem (at least if
understand the help for the path option correctly). If a path ends
with ** it searches only for directory names, while * searches only
the direct subdirectories for the given paths.
This is a good start, but what if I have a *lot* of paths I want to be
searchable (just think about Java and it's nice way of structuring
classes into packages ;).

So my subsequent question is:
Is there a way to set the path option programmatically. Say "scan dir
_x_ and add all subdirectories up to a given depth to the path
option"?
[snip]

Sure there is. You would have to write a shell or a Perl script that
would return a string of paths, given a depth level, separated by
commas. That script will take a base directory and a path depth level as
arguments. Then in Vim, you can do something like this:

  :let g:originalpath = &path
  :let &path = g:originalpath.system('myscript /scan/dir/_x_/ 4')

Or you can try this function that parses the output of the disk usage
'du' program:

  function! PathDepth(dir, depth)
    exe "let duresult = system('du --max-depth=".a:depth." ".a:dir."')"
    let duresult = substitute(duresult, '\d\+\t', ',', 'g')
    let duresult = substitute(duresult, '\n', '', 'g')
    return duresult
  endfunction

Then do

  :let &path = g:originalpath.PathDepth('/scan/dir/_x_/', 4)

HTH :)
--
Gerald

Reply via email to