From 724747b4aee363cf6adbfb3436b8ebe5c9296153 Mon Sep 17 00:00:00 2001 From: Andy Stewart Date: Wed, 31 Mar 2010 17:15:06 +0100 Subject: [PATCH] Search for files (ack -g). --- doc/ack.txt | 6 ++++++ plugin/ack.vim | 11 ++++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/doc/ack.txt b/doc/ack.txt index c653114c..75ba4b0f 100644 --- a/doc/ack.txt +++ b/doc/ack.txt @@ -34,6 +34,12 @@ shows the results in a split window. Just like |:Ack| + |:lgrepadd|. Searches, but appends results to |location-list| +:AckFile [options] {pattern} [{directory}] *:AckFile* + + Search recursively in {directory} (which defaults to the current + directory) for filenames matching the {pattern}. Behaves just like the + |:grep| command, but will open the |Quickfix| window for you. + Files containing the search term will be listed in the split window, along with the line number of the occurrence, once for each occurrence. on a line in this window will open the file, and place the cursor on the matching diff --git a/plugin/ack.vim b/plugin/ack.vim index fbc8b00b..318acc98 100644 --- a/plugin/ack.vim +++ b/plugin/ack.vim @@ -13,13 +13,17 @@ if !exists("g:ackprg") let g:ackprg="ack -H --nocolor --nogroup --column" endif -" Format, used to manage column jump -let g:ackformat="%f:%l:%c:%m" - function! s:Ack(cmd, args) redraw echo "Searching ..." + " Format, used to manage column jump + if a:cmd =~# '-g$' + let g:ackformat="%f" + else + let g:ackformat="%f:%l:%c:%m" + end + let grepprg_bak=&grepprg let grepformat_bak=&grepformat try @@ -51,3 +55,4 @@ command! -bang -nargs=* -complete=file AckAdd call s:Ack('grepadd', ', ) command! -bang -nargs=* -complete=file LAck call s:Ack('lgrep', ) command! -bang -nargs=* -complete=file LAckAdd call s:Ack('lgrepadd', ) +command! -bang -nargs=* -complete=file AckFile call s:Ack('grep -g', )