On Tue, 9 May 2006 at 9:57am, Gerald Lai wrote:

> On Tue, 9 May 2006, Benjamin Reitzammer wrote:
>
> [snip]
> >> Regarding :find. It does not do &path-full completion, and
> >> no 'incremental completion menu'. To write such plugin, you'd
> >> need to process every typed character.
> >
> > Yes I tried, :find and that it's not doing completion of my filename,
> > is something that makes it a lot less useful. Sure it broadened my vim
> > skills ;) but it's still not as good as the described solution the
> > jedit plugin offers.
> [snip]
>
> This has been suggested in the list before (by Hari, I think). Put these
> lines in your vimrc:
>
> ==
>    command! -nargs=? -complete=custom,PathFileComplete -bang -bar Find
find<bang> <args>
>    function! PathFileComplete(ArgLead, CmdLine, CursorPos)
>      return substitute(globpath(&path, a:ArgLead."*"), "[^\n]\\+/", "", "g")
>    endfunction
>
>    set wildmenu wildmode=longest:full
> ==
>
> Then instead of doing
>
>    :find <partial filename>
>
> do
>
>    :Find <partial filename>
>    (notice the capital "F")
>
> Completion will work now. :Find is :find with completion.
>
> Take note of what Jürgen & Tim had to say. :Find will look in the
> directories specified in the option 'path', as Jürgen mentioned.
>
> After typing your <partial filename>, you can hit the <Tab> button, as
> Tim mentioned, to complete the filename and/or bring up the wildmenu so
> you can scroll through the matching filenames from left to right. You
> can also type Ctrl-d to list the matching filenames.
>
> HTH :)
> --
> Gerald

Yes, that was me, thanks for the plug. You need genutils.vim for the
function that is used. However, I remember someone mentioning a program
(is it called lookup?) that indexes filenames and can support fast
lookup of filenames by keywords. Another simple idea would be to
generate a file with the Vim tag format, and use :ts (or the new
tagselect()) to select a matching file. We can probably combine this
with getchar() and inputselect() to show the matched filenames and allow
user to select one. The simplest tag format should suffice (as per
tags-file-format):

{filename}              {TAB} {filename} {TAB} {1}

I used the below command to generate a tag file:

find . -print | sort | awk '{printf "%s\t%s\t1\n", $0, $0;}' > filenametags

And when I set this file as tags file:

:set tags=./filenametags

I was able to use the below format to lookup filenames:

:ts /xxx

I could also combine this with my tagselect plugin to make selection a
bit easier, but would be ideal is to do this tranparently through a
function, something like:

let _tags=&tags
set tags=./filenametags
try
    " read partial string
    " lookup tags, prefixing the partial string with a /.
    " Present the tags and allow user to select one.
finally
    let &tags=_tags
endtry

Now all that you need to do is to schedule a command to refresh the tag
format.

-- 
HTH,
Hari

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

Reply via email to