Skip to content

Vim fzf - Project Root

Serhat Teker on May 18, 2019

What is fzf? fzf is a general-purpose command-line fuzzy finder written in Go. fzf is a fuzzy finder for your terminal, it is a command ... [Read Full]
markdown guide

The problem is that when you return a new file in current buffer it changes :Files directory.

It doesn't change current working directory for me (here's a demo)? It did for you?

PS. Great post though! Have you checked out the other cool things fzf.vim can do?


Actually I figured out long before that the problem is not :Files, it is my other conf in my vimrc:

" Enter automatically into the files directory
autocmd BufEnter * silent! lcd %:p:h

I should update this old (cross) post accordingly :)

Thanks for your comment. I look at your post and it is so awesome. I almost use them all as well.

Btw. which tool do you use to record your screen?


Hi, Serhat. Awesome post indeed. I had the same problem as you. I used "set autochdir" because of Nerdtree (to always open the nerdtree window to the right directory), however, when I look for any file using fzf it only looks for the current directory (not the root path if I open a file in a subfolder). How did you solve it? Thanks in advance!

Hi Paulo. Thanks a lot. My ideal solution suggestion would be don't use autochdir at all. I don't use it anymore. I cd into project root then make the search, edit etc.

However if you like to use it though, there are 3 solutions for it:

1 - Using above solution of mine. Add them in your .vimrc
2 - Using :Gfiles command of fzf.vim plugin
3 - Add 'dbakker/vim-projectroot' plugin and map necessary command like below. My mapping is "Ctrl+P" but you can modify according to your favorites.

map <C-p> :<C-u>ProjectRootExe Files<CR>

Tell me these fixes solve your issue.

code of conduct - report abuse