Skip to content

Commit

Permalink
Working ack find :)
Browse files Browse the repository at this point in the history
  • Loading branch information
Marcus Vorwaller committed Feb 9, 2010
1 parent 7dd1721 commit f790f87
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 39 deletions.
36 changes: 33 additions & 3 deletions doc/ack.txt
@@ -1,8 +1,14 @@
*ack.txt* Plugin that integrates ack with Vim

==============================================================================
Author: Antoine Imbert <antoine.imbert+ackvim@gmail.com> *ack-author*
License: Same terms as Vim itself (see |license|)
License: Same terms as Vim itself (see |license|) *ack-author*
Authors:

All the blame for the current version should go
to Vladimir Dobriakov (http://blog.geekQ.net).

All the praise for the original idea should go to
Antoine Imbert and Miles Z. Sterrett.

==============================================================================
INTRODUCTION *ack*
Expand Down Expand Up @@ -35,4 +41,28 @@ with the line number of the occurrence, once for each occurrence. <Enter> on
a line in this window will open the file, and place the cursor on the matching
line.

See http://search.cpan.org/~petdance/ack/ack for more information.
See |quickfix| and |:cnext| for more information about efficient
navigation in Quickfix window.

:AckG [options] {file_pattern} [{directory}] *:AckG*

ack is also great for searching files by name, e.g. `ack -g user`
will find all files, which have /user/ in its name. So this plugin
can also act as an alternative to fuzzyfinder.vim
:AckG user
does the search and lists the files in the |Quickfix| window. Move
with 'j', 'k' and press <Enter> to open the file.
(Feature by Vladimir Dobriakov http://blog.geekq.net)

You can also map the commands in your .vimrc with

nmap <silent> <unique> <Leader>a :Ack
nmap <silent> <unique> <Leader>g :AckG

Then use `\g user` in |Normal-mode| to search for files, that contain
`user` in its name or path or use `\a hello` to search for `hello` in
file content.

See http://search.cpan.org/~petdance/ack/ack and
http://betterthangrep.com/ for more information.

1 change: 1 addition & 0 deletions doc/tags
Expand Up @@ -65,6 +65,7 @@
/MyProjectDir/ dbext.txt /*\/MyProjectDir\/*
:Ack ack.txt /*:Ack*
:AckAdd ack.txt /*:AckAdd*
:AckG ack.txt /*:AckG*
:AcpDisable acp.txt /*:AcpDisable*
:AcpEnable acp.txt /*:AcpEnable*
:AcpLock acp.txt /*:AcpLock*
Expand Down
3 changes: 2 additions & 1 deletion filetype.vim
@@ -1,8 +1,9 @@
augroup filetypedetect
au BufNewFile,BufRead .tmux.conf*,tmux.conf* setf tmux
autocmd BufNewFile,BufRead *.mkd setf mkd
augroup END

" Markdown
augroup mkd
autocmd BufRead *.mkd set ai formatoptions=tcroqn2 comments=n:&gt;
autocmd BufNewFile,BufRead *.mkd set ai formatoptions=tcroqn2 comments=n:&gt;
augroup END
3 changes: 2 additions & 1 deletion notes/vim.mkd
Expand Up @@ -109,7 +109,8 @@ N last / or ? search in opposite direction
# ctrl-^ Open buffer number <#>
ctrl-^/ ctrl-6 / :b# Open previous buffer
ZZ Save and close current buffer

*Bufexplorer*
\be, \bs, \bv Normal open, horizontal splt, vertical split

*Running system commands*
:! <command> %(current file) run a system command optionally with current file as %
Expand Down
50 changes: 16 additions & 34 deletions plugin/ack.vim
Expand Up @@ -6,45 +6,27 @@
" With MacPorts:
" sudo port install p5-app-ack

let g:ackprg="ack\\ -H\\ --nocolor\\ --nogroup"
let g:ackprg="ack\\ -H\\ --nocolor\\ --nogroup\\ --column"

function! Ack(args)
function! Ack(command, format, list, args)
let grepprg_bak=&grepprg
exec "set grepprg=" . g:ackprg
execute "silent! grep " . a:args
botright copen
let grepformat_bak=&grepformat
exec "set grepformat=" . a:format
execute "silent! " . a:command . " " . a:args
if a:list == "quickfix"
botright copen
else
botright lopen
endif
let &grepprg=grepprg_bak
let &grepformat=grepformat_bak
exec "redraw!"
endfunction

function! AckAdd(args)
let grepprg_bak=&grepprg
exec "set grepprg=" . g:ackprg
execute "silent! grepadd " . a:args
botright copen
let &grepprg=grepprg_bak
exec "redraw!"
endfunction

function! LAck(args)
let grepprg_bak=&grepprg
exec "set grepprg=" . g:ackprg
execute "silent! lgrep " . a:args
botright lopen
let &grepprg=grepprg_bak
exec "redraw!"
endfunction

function! LAckAdd(args)
let grepprg_bak=&grepprg
exec "set grepprg=" . g:ackprg
execute "silent! lgrepadd " . a:args
botright lopen
let &grepprg=grepprg_bak
exec "redraw!"
endfunction
command! -nargs=* -complete=file Ack call Ack("grep!", "%f:%l:%c:%m", "quickfix", <q-args>)
command! -nargs=* -complete=file AckAdd call Ack("grepadd!", "%f:%l:%c:%m", "quickfix", <q-args>)
command! -nargs=* -complete=file LAck call Ack("lgrep!", "%f:%l:%c:%m", "location-list", <q-args>)
command! -nargs=* -complete=file LAckAdd call Ack("lgrepadd!","%f:%l:%c:%m", "location-list", <q-args>)

command! -nargs=* -complete=file Ack call Ack(<q-args>)
command! -nargs=* -complete=file AckAdd call AckAdd(<q-args>)
command! -nargs=* -complete=file LAck call LAck(<q-args>)
command! -nargs=* -complete=file LAckAdd call LAckAdd(<q-args>)
command! -nargs=* -complete=file AckG call Ack("grep! -g", "%f", <q-args>)

0 comments on commit f790f87

Please sign in to comment.