diff --git a/autoload/ack.vim b/autoload/ack.vim index b6afdba4..31c0aea0 100644 --- a/autoload/ack.vim +++ b/autoload/ack.vim @@ -77,6 +77,18 @@ function! ack#AckHelp(cmd, args) "{{{ call ack#Ack(a:cmd, args) endfunction "}}} +function! ack#AckBuffer(cmd, args) "{{{ + let l:bufs = filter(range(1, bufnr('$')), 'buflisted(v:val)') + let l:files = [] + for buf in l:bufs + let l:file = shellescape(fnamemodify(bufname(buf), ':p')) + if !isdirectory(l:file) + call add(l:files, l:file) + endif + endfor + call ack#Ack(a:cmd, a:args . ' ' . join(l:files, ' ')) +endfunction "}}} + function! ack#AckWindow(cmd, args) "{{{ let files = tabpagebuflist() diff --git a/doc/ack.txt b/doc/ack.txt index 22e884bc..d248238f 100644 --- a/doc/ack.txt +++ b/doc/ack.txt @@ -22,6 +22,12 @@ shows the results in a split window. will open the |Quickfix| window for you. If [!] is not given the first occurrence is jumped to. +:AckBuffer[!] [options] {pattern} *:AckBuffer* + + Search for {pattern} in all open buffers. Behaves just like the |:grep| + command, but will open the |QuickFix| window for you. If [!] is not given + the first error is jumped to. + :AckAdd [options] {pattern} [{directory}] *:AckAdd* Just like |:Ack|, but instead of making a new list, the matches are @@ -36,6 +42,11 @@ shows the results in a split window. Just like |:Ack| but instead of the |quickfix| list, matches are placed in the current |location-list|. +:LAckBuffer [options] {pattern} [{directory}] *:LAckBuffer* + + Just like |:AckBuffer| but instead of the |quickfix| list, matches are + added to the current |location-list| + :LAckAdd [options] {pattern} [{directory}] *:LAckAdd* Just like |:AckAdd| but instead of the |quickfix| list, matches are added diff --git a/plugin/ack.vim b/plugin/ack.vim index 202ae2ea..1872de2a 100644 --- a/plugin/ack.vim +++ b/plugin/ack.vim @@ -68,9 +68,11 @@ if !exists("g:ack_use_cword_for_empty_search") endif command! -bang -nargs=* -complete=file Ack call ack#Ack('grep', ) +command! -bang -nargs=* -complete=file AckBuffer call ack#AckBuffer('grep', ) command! -bang -nargs=* -complete=file AckAdd call ack#Ack('grepadd', ) command! -bang -nargs=* -complete=file AckFromSearch call ack#AckFromSearch('grep', ) command! -bang -nargs=* -complete=file LAck call ack#Ack('lgrep', ) +command! -bang -nargs=* -complete=file LAckBuffer call ack#AckBuffer('lgrep', ) command! -bang -nargs=* -complete=file LAckAdd call ack#Ack('lgrepadd', ) command! -bang -nargs=* -complete=file AckFile call ack#Ack('grep -g', ) command! -bang -nargs=* -complete=help AckHelp call ack#AckHelp('grep', )