mirror of
https://github.com/junegunn/fzf.git
synced 2025-11-18 08:13:40 -05:00
add snippet to fuzzy search neigbouring files
@@ -360,3 +360,23 @@ command! -nargs=* Ag call fzf#run({
|
|||||||
\ 'down': '50%'
|
\ 'down': '50%'
|
||||||
\ })
|
\ })
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### 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)
|
||||||
|
|
||||||
|
```vim
|
||||||
|
function! s:fzf_neighbouring_files()
|
||||||
|
let current_file =expand("%")
|
||||||
|
let cwd = fnamemodify(current_file, ':p:h')
|
||||||
|
let command = 'ag -g "" -f ' . cwd . ' --depth 0'
|
||||||
|
|
||||||
|
call fzf#run({
|
||||||
|
\ 'source': command,
|
||||||
|
\ 'sink': 'e',
|
||||||
|
\ 'options': '-m -x +s',
|
||||||
|
\ 'window': 'enew' })
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
command! FZFNeigh call s:fzf_neighbouring_files()
|
||||||
|
```
|
||||||
Reference in New Issue
Block a user