i.e., if I had a file structure like
.
./directory1
./directory1/file1
./directory1/file2
./directory2
./directory2/file1
./directory2/file2
and I typed :find file2 I would like it to present me
with a list of matching files and allow me to select
the file to edit. Is this possible today?
Is there a way I can use the find from the shell to
invoke this functionality?
Thanks,
Dennis
> i.e., if I had a file structure like
> .
> ./directory1
> ./directory1/file1
> ./directory1/file2
> ./directory2
> ./directory2/file1
> ./directory2/file2
> and I typed :find file2 I would like it to present me
> with a list of matching files and allow me to select
> the file to edit. Is this possible today?
It's doable, if you don't mind traversing the directories yourself in a
user defined function. Approach is pretty much like below, except you'd
need to do it without extarnal commands.
> Is there a way I can use the find from the shell to
> invoke this functionality?
How about this:
:fun Find(path, ...)
return system('find "' . a:path . '" -type f')
endfun
:com -nargs=1 -complete=custom,Find Find
There are probably some very rough edges, but as a quick hack it does
the trick for me.
Peppe
--
se nocp cpo=BceFsx!$ hid bs=2 ls=2 hls ic " P. Guldberg /bin/v...@wielders.org
se scs ai isf-== fdo-=block cino=t0,:0 hi=100 ru so=4 noea lz|if has('unix')
se sh=/bin/sh|en|syn on|filetype plugin indent on|ono S V/\n^-- $\\|\%$/<CR>
cno <C-A> <C-B>|au FileType vim,mail se sw=4 sts=4 et|let&tw=72+6*(&ft=~'v')
thanks,
Dennis
[You have not given much context for your questions. When following up
on specific points, please quote enough context to identify it. Thanks.]
On systems that has find, that command should do it, as mentioned.
Did this work for you?
Or do you mean a python enabled vim? I don't think this is necessary.
> I didn't see any built in functions that would give this
> to me.
I haven't tried, but using globpath() and isdirectory() should help you
recurse down through a directory tree. globpath() and filereadable()
and/or filewritable() should help you work with individual files.
> Also, when I do have the list of files, how to I get them in an
> error list or something so I can navigate them like when I use grep?
How much trouble are you willing to go through?
I would probably put the list in a new buffer and do
:%s/$/:1:dummy/ " fake some context
:w
:cf %
It's manual work, but does the trick quickly.
>Or do you mean a python enabled vim? I don't think this is necessary.
I am using windows which doesn't have find. I downloaded the GNU find,
but I can use the backticks to call it from VIM.
>How much trouble are you willing to go through?
As much as it takes. Besides being useful for me, it is a learning
experience.
>I would probably put the list in a new buffer and do
> :%s/$/:1:dummy/ " fake some context
> :w
> :cf %
>It's manual work, but does the trick quickly.
Can I put hyperlinks around the file path and pass it to vim, that way
I can jump straight to it somehow (like the help system)?
thanks,
Dennis
> >Or do you mean a python enabled vim? I don't think this is necessary.
> I am using windows which doesn't have find. I downloaded the GNU find,
> but I can use the backticks to call it from VIM.
> >How much trouble are you willing to go through?
> As much as it takes. Besides being useful for me, it is a learning
> experience.
I think writing a function to traverse directories and finding files
based on some criteria, using only vim internal commands would be a good
learning experience :-)
I am quite convinced that it is possible using the functions I pointed
you to earlier.
> >I would probably put the list in a new buffer and do
> > :%s/$/:1:dummy/ " fake some context
> > :w
> > :cf %
> >It's manual work, but does the trick quickly.
> Can I put hyperlinks around the file path and pass it to vim, that way
> I can jump straight to it somehow (like the help system)?
As long as the files are relative to somewhere in the 'path' option,
simply using the gf and <C-W>f normal mode commands should work without
problems. Simply place the cursor on a file name and type "gf".