diff --git a/examples.md b/examples.md index 6b719fe..921756a 100644 --- a/examples.md +++ b/examples.md @@ -141,4 +141,24 @@ fo() { file=$(fzf --query="$1" --select-1 --exit-0) [ -n "$file" ] && open "$file" } -``` \ No newline at end of file +``` + +narrow ag results within vim +---- + +add this to your .vimrc + +```vimL +command! -nargs=1 AgFZF call fzf#run({ + \'source': 'ag -i ' . , + \'sink' : function('AgHandler'), + \'options' : '-m' + \}) + +function! AgHandler(l) + let keys = split(a:l,':') + execute 'tabe +' . keys[1] . ' ' . keys[0] +endfunction +``` + +Then use `:AgFZF` followed by an ag-recogizable regex to pipe ag results into FZF for narrowing. Selected results are opened in new tabs so that you can open multiple positions within the same file (perhaps there's a better way of doing this). \ No newline at end of file