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?

up vote 1 down vote accepted

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. – Salahuddin Ahmed Aug 9 at 9:31
  • Not according to the current documentation – Christian Brabandt Aug 9 at 10:12
  • 'autochdir' has never defaulted on ON for nvim. – jamessan Aug 9 at 18:15

Your Answer


By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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