m/fzf
1
0
mirror of https://github.com/junegunn/fzf.git synced 2025-11-19 17:13:42 -05:00

Improve FZFLines example

Junegunn Choi
2014-07-04 02:44:48 -07:00
parent 25b3902a34
commit 4d45c1b628

@@ -167,29 +167,27 @@ 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).
search lines in all open vim buffers
Search lines in all open vim buffers
---
```vimL
command! FZFLines call fzf#run({
\'source': BuffersLines(),
\'sink' : function('LineHandler'),
\})
\ 'source': BuffersLines(),
\ 'sink': function('LineHandler'),
\ 'options': '--extended --nth=3..,'
\})
function! LineHandler(l)
let keys = split(a:l,' ')
exec 'buf ' . keys[0]
let line = join(keys[4:-1])
exec search(escape(line, '\\/.*$^~[]'))
let keys = split(a:l, ':\t')
exec 'buf ' . keys[0]
exec keys[1]
normal! ^zz
endfunction
function! BuffersLines()
let all = range(1, bufnr('$'))
let res = []
for b in all
if buflisted(b)
let res = res + map(getbufline(b,0,"$"), 'b . " -- " . (v:key + 1) . " -- " . v:val ')
endif
for b in filter(range(1, bufnr('$')), 'buflisted(v:val)')
call extend(res, map(getbufline(b,0,"$"), 'b . ":\t" . (v:key + 1) . ":\t" . v:val '))
endfor
return res
endfunction