When I use :Files
in fzf.vim, it searches for the files in the current directory and the subdirectories. The current working directory is fixed. In the screenshot below, it is in light blue. Is there a way to dynamically change the working directory on which FZF is run? For example, if I just delete "Documents" path, then FZF starts on ~ instead of ~/Documents.
Such functionality is possible in Emacs helm package, which allows this through helm-execute-persistent-action.
You could change the current working directory vim is currently using the :chdir
or the familiar :cd
command. See :h cd
for more info.
And if you don't want to change the working directory of vim and just want fzf to use a different directory, you could run fzf (:h fzf#run
) with a custom dir
option.
This is an example mapping I have in my ~/.vimrc
to open a file within my /.vim
directory:
nnoremap <leader>fv :call fzf#run({'options': '--reverse --prompt "VimFiles"', 'down': 20, 'dir': '~/.vim/', 'sink': 'e' })<CR>
For dynamic path you add a command that takes the path as an argument, make sure to use the completion as file for tab completing the path. see this answer for more info on file completion.
The sink
option tells what to do/perform when a match is found. and e
is for editing the main window.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With