diff --git a/Examples-(vim).md b/Examples-(vim).md index da4e7a4..1ecdf58 100644 --- a/Examples-(vim).md +++ b/Examples-(vim).md @@ -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) @@ -381,4 +381,32 @@ function! s:fzf_neighbouring_files() endfunction 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)')}, 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}')) + \ }, 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 ``` \ No newline at end of file