> But i don't know why it doesn't work with Windows (I already installed perl
> in order for it to work). It keep saying Can't find string terminator.
The entire error message you should be seeing is
Can't find string terminator "'" anywhere before EOF at -e line 1.
Which is an error message from Perl. This occurs on line 2 of the
function, in the system() call. I believe it has to do with cmd.exe's
crappy rules about single and double quotes. In short, don't use
single quotes in cmd.exe.
I changed that line so it would work on Windows:
let l:list=system("find . -iname '*".l:_name."*' -not -name \"*.class\" -and -not -name \"*.swp\" -and -not -name \".*\" | perl -ne \"print \\\"$.\\t$_\\\"\"")
However, this script makes use of the UNIX find utility. Windows
ships with its own find.exe, which doesn't use the same switches and
arguments as the UNIX one. On Windows, that command will never find
your file, and you always get the message that your file is not found.
You can install the Win32 port of the UNIX find utility and try again.
It's located here:
http://gnuwin32.sourceforge.net/packages/findutils.htm
After you install it, make sure its directory appears in your %PATH%
before C:\WINDOWS\system32, or else Vim will probably run the original
Windows version.
I still couldn't get it to find my file, but this should be a good
start. Now, I need to get back to my day job!
Good luck
--
Erik Falor
Registered Linux User #445632 http://counter.li.org
To find all files with a given name at any depth in the current
directory or below, you need neither perl nor a plugin. Nor any
particular external program, in fact. Just use
:vimgrep /\%1l/ **/filename.ext
It will generate a list of matches which you can open with
:copen
You can then jump to any match by hitting Enter on the appropriate line.
Or you can view all matching files in sequence by means of
:cnext
:cprev
:cfirst
:clast
(for next, previous, first and last match respectively, of course). See
":help quickfix.txt" for details. The idea of the vimgrep command above
is to match "the first line" of any file of the given name at any depth
(since we have to match "something" in the file's contents).
Best regards,
Tony.
--
Experience is what you get when you don't get what you want.
We recently agreed on a "How to post messages" recommendation:
http://groups.google.com/group/vim_use/web/vim-information
Bear in mind that other people read these messages, and it would be a lot more
helpful if you would quote the brief text you are referring to, then give your reply
(underneath).
What do you mean "it simply don't work"? You typed the command (what command?), and
you got an error message? Or nothing was displayed?
Tony clearly spelled out that you have to enter two commands:
:vimgrep /\%1l/ **/filename.ext
:copen
Obviously you replace "filename.ext" with the name you want.
Assuming you don't have an obsolete version of Vim, Tony's commands work perfectly.
As he stated, there is no need for a plugin (although the vimgrep method is a bit
slow when searching many hundreds of files).
John
I decided that it shouldn't be hard to whip up a command. Following is the result,
and it might make quite a nice tip (with Tony's vimgrep solution) when checked:
" List full paths of files matching specification (MS Windows).
" Result is placed in a scratch buffer.
" Examples:
" :Ls my*.c
" :Ls ..\my*.c
" :Ls my.txt*
" Use last line if my.txt only exists in a subdirectory.
" Type gf to open file under cursor.
" gf is mapped so it will open files with spaces in name.
function! ListFiles(filespec)
new
setlocal buftype=nofile bufhidden=hide noswapfile
nnoremap <buffer> gf _y$:e <C-r>"<CR>
execute '0r !xcopy '.a:filespec.' \con\ /s /h /l'
silent! $-1g/File(s)\n$/.,.+1d
1
endfunction
command! -nargs=1 Ls call ListFiles('<args>')
" TODO:
" - Don't change unnamed register (in gf mapping).
" - Use appropriate command for Unix if on that platform.
" - Option to make quickfix list might be good.
Windows users: Please give this a try and report if it is ok.
Other users: Please offer suggestions.
John
As a similar item, there's also the :Explore **/filespec command
available with netrw. Here's some of the help for it and
some similar commands:
*/filepat files in current directory which satisfy filepat
**/filepat files in current directory or below which satisfy the
file pattern
*//pattern files in the current directory which contain the pattern
(vimgrep is used)
**//pattern files in the current directory or below which contain
the pattern (vimgrep is used)
Regards,
Chip Campbell