When opening neovim via nvim /path/to/directory I want the current working directory of vim to be set to the given path instead of the current path of my terminal.

When opening a file instead it would make sense to me that the current working directory is set to the parent directory and when opening a new file or without arguments the default behavior would be fine.

Is there any option to accomplish something like this? I am aware of autochdir but it does not seem like what I want.

Background is that I want my fuzzy finder to look for file in the correct location when opening vim without having to remember to cd into that directory first.

  • Do you mean you want to do this through configuration (i.e. in your vimrc) or more of an as-needed, adhoc basis? The latter can be done with command line params: vim -c "lcd $PWD" /some/file.
    – B Layer
    Oct 30, 2021 at 20:28
  • I want this as a default configuration rather than a command like the above.
    – dehlen
    Oct 30, 2021 at 20:30

1 Answer 1


As long as you're in an environment that uses the PWD environment variable then you can use that with the :cd command in a VimEnter autocommand. For example...

augroup cdpwd
    autocmd VimEnter * cd $PWD
augroup END

This will run once after Vim/NeoVim first initializes.

(Tested successfully with an init.vim file containing only the above.)

  • Thank you looks like what I wanted!
    – dehlen
    Oct 30, 2021 at 20:54
  • Great! You're welcome.
    – B Layer
    Oct 30, 2021 at 20:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.