'autochdir' 'acd'   boolean (default off)
            {not in Vi}
            {only available when compiled with it, use
            exists("+autochdir") to check}
    When on, Vim will change the current working directory whenever you
    open a file, switch buffers, delete a buffer or open/close a window.
    It will change to the directory containing the file which was opened
    or selected.
    This option is provided for backward compatibility with the Vim
    released with Sun ONE Studio 4 Enterprise Edition.
    Note: When this option is on some plugins may not work.

What are all of the hooks that you'd have to listen to to simulate autochdir?

I guess at least one would look like this

autocmd BufEnter * :cd expand('%:p:h')

How can all of the functionality of autochdir be implemented?

  • From a cursory look at the code, "hooks" and "listening" are not involved. The macro is called explicitly (search for do_autochdir).
    – romainl
    Mar 24 at 18:06


Your Answer

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

Browse other questions tagged or ask your own question.