diff --git a/examples.md b/examples.md index 1f2fb10..7be2ce1 100644 --- a/examples.md +++ b/examples.md @@ -165,4 +165,32 @@ function! Arghandler(l) 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 +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 +--- + +```vimL +command! FZFLines call fzf#run({ + \'source': BuffersLines(), + \'sink' : function('LineHandler'), + \}) + +function! LineHandler(l) + let keys = split(a:l,' ') + exec 'buf ' . keys[0] + let line = join(keys[4:-1]) + exec search(escape(line, '\\/.*$^~[]')) +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 + endfor + return res +endfunction +``` \ No newline at end of file