I'm trying to disable autochdir in nvim by adding the following in init.vim:

set autochdir!

but when I start nvim, I check the value of this option by echo &autochdir and find it equals to 1.

I though it may be overwritten by Python filetype as mentioned these two posts (Why is “set noexpandtab” in my ~/.vimrc ignored when I open a file? and Vim displaying incorrect indentation).So I tried adding the following to my vimrc:

augroup python
    autocmd FileType python set autochdir!
augroup end

but it doesn't solve the problem.

Why is this option overwritten and how can I force it?

1 Answer 1


Something funny is going on here. If you want to disable the 'autochdir', use

:set noautochdir

If you use the the !, this means it basically toggles the option. So whenever you happen to resource your .vimrc (or init.vim) file it silently toggles the value, which might be unexpected.

However, if you read the help for that setting, it clearly indicates this option is off by default. So you can also just skip the whole command at all ;)

augroup python
    autocmd FileType python set autochdir!
augroup end

Secondly your autocommand may work fine and disable the autochdir. Sadly, this might come to late so that Nvim already switched to the specified directory and only afterwards it turns off the setting.

You can always check the option value when it was set and by what script by using:

:verbose set autochdir?

In general I would always recommend to either leave this global option off, or on. But do not toggle it often within a session. It might be confusing, but your mileage may vary.

  • I didn't pay attention to the toggle point. Thanks for clarifying it. In nvim, I think this option is ON by default. At least this is how it behaved before. Commented Aug 9, 2018 at 9:31
  • Not according to the current documentation Commented Aug 9, 2018 at 10:12
  • 'autochdir' has never defaulted on ON for nvim.
    – jamessan
    Commented Aug 9, 2018 at 18:15

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.