Findmate plugin not working in Windows

2 views
Skip to first unread message

Shade -

unread,
Dec 3, 2008, 9:09:48 AM12/3/08
to vim...@googlegroups.com
Hi!

Two of my friends made a really nice plugin. With this plugin you can just use

:Findmate nameoffile

And it looks trough the folders and subfolders that you are at, searching for files with that name. Displaying it in a list. And then you can just press 1-X in order to open the file that you desire.

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.

Can anybody help me with it please? I already gave up :(

Here is the plugin: http://www.masquesoft.net/vim/findmate.vim

Thanks all in advance.

Erik Falor

unread,
Dec 3, 2008, 12:46:45 PM12/3/08
to vim...@googlegroups.com
On Wed, Dec 03, 2008 at 03:09:48PM +0100, Shade - wrote:

> 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

Tony Mechelynck

unread,
Dec 3, 2008, 5:52:56 PM12/3/08
to vim...@googlegroups.com

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.

Shade -

unread,
Dec 4, 2008, 4:03:41 AM12/4/08
to vim...@googlegroups.com
Well... it simply don't work (the vimgrep).

Erik, thank you so much for your tip. Looks like it fixes that error msg but now if just keep saying: "XXXXX not found" where XXXXX is the filename that i try to search. I will keep looking at it.

Thanks again.

John Beckett

unread,
Dec 4, 2008, 5:01:33 AM12/4/08
to vim...@googlegroups.com
Shade wrote:
> Well... it simply don't work (the vimgrep).

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

John Beckett

unread,
Dec 4, 2008, 11:39:26 PM12/4/08
to vim...@googlegroups.com
Strange how the world turns ... I found myself wanting this functionality a few
hours ago, that is, quickly list all files matching a filespec, on a Windows system.

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

Charles Campbell

unread,
Dec 5, 2008, 11:08:47 AM12/5/08
to vim...@googlegroups.com
John Beckett wrote:
> Strange how the world turns ... I found myself wanting this functionality a few
> hours ago, that is, quickly list all files matching a filespec, on a Windows system.
>
[snip]

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


Reply all
Reply to author
Forward
0 new messages