Thanks Gerald. I'm not familiar with globpath although a quick :help taught me all I needed to know. A quick poke shows that it works rather nicely; if a bit slowly, we have around 100 first level directories in source, each of which has 20-100 files and sub directories (although thankfully not many more than two levels of directories!).
My only question is whether globpath has some unwritten limit on the number of files it can deal with. If I try to do :sf a<tab> then it is likely to turn up a couple of hundred files. And yes I respect that the answer might just be "don't do that, you fool". :) Also, is there any (easy) way to have user defined commands starting with a lowercase letter? In all honesty I will probably not make use of Sfind and instead put up with typing the full name myself, just because I won't be able to train myself out of typing :sf. Thanks! Max > -----Original Message----- > From: Gerald Lai [mailto:[EMAIL PROTECTED] > Sent: Tuesday, June 06, 2006 2:40 PM > To: Max Dyckhoff > Cc: vim org > Subject: Re: Tab complete filenames > > On Tue, 6 Jun 2006, Max Dyckhoff wrote: > > > I am wondering if there is any way to get the tab completion of a > > command to open a new file to complete any file in the path, not just > > those in the current working directory. Basically, my path variable is: > > > > path=.,c:\...\source,c:\...\source** > > > > and I would like to be able to enter > > > > :sf behavior_fi<tab><enter> > > > > For it to open the file ...\source\ai\behaviour\behavior_fight.inl, > > which it won't currently do. Any bright ideas? > [snip] > > This was recently discussed on the list (I don't remember when). You can > place something like this in your vimrc: > > command! -nargs=? -complete=custom,PathFileComplete -bang -bar Sfind > sfind<bang> <args> > function! PathFileComplete(ArgLead, CmdLine, CursorPos) > return substitute(globpath(&path, a:ArgLead."*"), "[^\n]\\+/", "", > "g") > endfunction > > Instead of using :sfind, use :Sfind (note the capital S). However, if > you have duplicate filenames in the path, you may want to use this > instead so you can specify a count for which duplicate found file is > opened: > > command! -nargs=? -complete=custom,PathFileComplete -count=1 -bang -bar > Find <count>find<bang> <args> > > So if there are 2 "behavior_fight.inl" files, :2Find behavior_fight.inl > will open the second one. > > Kudos to Hari for the completion function! > > HTH :) > -- > Gerald
