mirror of
https://github.com/junegunn/fzf.git
synced 2025-11-20 09:33:42 -05:00
A little FZF powered ag wrapper for vim.
22
examples.md
22
examples.md
@@ -141,4 +141,24 @@ fo() {
|
|||||||
file=$(fzf --query="$1" --select-1 --exit-0)
|
file=$(fzf --query="$1" --select-1 --exit-0)
|
||||||
[ -n "$file" ] && open "$file"
|
[ -n "$file" ] && open "$file"
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
narrow ag results within vim
|
||||||
|
----
|
||||||
|
|
||||||
|
add this to your .vimrc
|
||||||
|
|
||||||
|
```vimL
|
||||||
|
command! -nargs=1 AgFZF call fzf#run({
|
||||||
|
\'source': 'ag -i ' . <f-args>,
|
||||||
|
\'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).
|
||||||
Reference in New Issue
Block a user