From 8d15f84637d9f2c35840b232b7d4275d87eaee51 Mon Sep 17 00:00:00 2001 From: Alexander Jeurissen Date: Thu, 26 Oct 2017 16:44:18 +0200 Subject: [PATCH] add snippet to fuzzy search neigbouring files --- Examples-(vim).md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/Examples-(vim).md b/Examples-(vim).md index 44f8e9d..f314c0f 100644 --- a/Examples-(vim).md +++ b/Examples-(vim).md @@ -359,4 +359,24 @@ command! -nargs=* Ag call fzf#run({ \ '--color hl:68,hl+:110', \ '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() ``` \ No newline at end of file