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

Add examples to fuzzy search the arglist and netrwhist

kiryph
2019-04-04 11:48:08 +02:00
parent 657f0ca149
commit b2ac6df440

@@ -363,7 +363,7 @@ command! -nargs=* Ag call fzf#run({
\ }) \ })
``` ```
### fuzzy search files in parent directory of current file ### Fuzzy search files in parent directory of current file
This command is very handy if you want to explore or edit the surrounding/neigbouring files of the file your currently editing. (e.g. files in the same directory) This command is very handy if you want to explore or edit the surrounding/neigbouring files of the file your currently editing. (e.g. files in the same directory)
@@ -382,3 +382,31 @@ endfunction
command! FZFNeigh call s:fzf_neighbouring_files() command! FZFNeigh call s:fzf_neighbouring_files()
``` ```
### Fuzzy search the arglist (`:Args`)
```viml
command! -bang Args call fzf#run(fzf#wrap('args',
\ {'source': map([argidx()]+(argidx()==0?[]:range(argc())[0:argidx()-1])+range(argc())[argidx()+1:], 'argv(v:val)')}, <bang>0))
```
### Fuzzy search netrwhist (`:Netrwhist`)
```viml
function! MyUniq(lst)
return filter(a:lst, 'count(a:lst, v:val) == 1')
endfunction
command! -bang Netrwhist call fzf#run(fzf#wrap('netrw_dirhist',
\ {'source':
\ !exists('g:netrw_dirhist_cnt')
\ ?"tail -n +3 ".g:netrw_home.".netrwhist | cut -d \"'\" -f2- | rev | cut -d \"'\" -f2- | rev | awk '!seen[$0]++'"
\ :MyUniq(map(range(1,g:netrw_dirhist_cnt), 'g:netrw_dirhist_{v:val}'))
\ }, <bang>0))
```
This uses the command line tools `tail`, `cut`, `rev`, and `awk` which are most likely available under macOS and Linux.
The default value of `g:netrw_dirhistmax` is 10. You might be interested in increasing this value when you use this feature more often:
```viml
let g:netrw_dirhistmax = 1000
```