mirror of
https://github.com/junegunn/fzf.git
synced 2025-11-18 16:45:38 -05:00
Add examples to fuzzy search the arglist and netrwhist
@@ -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)
|
||||||
|
|
||||||
@@ -381,4 +381,32 @@ function! s:fzf_neighbouring_files()
|
|||||||
endfunction
|
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
|
||||||
```
|
```
|
||||||
Reference in New Issue
Block a user