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
--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---