Change the startup behavior of Vim to follow your path.
Have you ever started Vim from the command line with a path argument and were surprised to discover that Vim was operating on a completely different path than what you expected? ๐
Do you think it would be awesome if Vim's current working directory was derived from the path argument?
Well this could be the perfect plugin for you! ๐
No more fussing with having to manually change the current working directory after startup. MWD is a simple plugin that handles this task for you automatically and requires zero-configuration.
Why not use Vim's built-in autochdir feature?
It simply doesn't fit my workflow. I would like Vim to stay in my workspace path or what is also known as the project's root. Autochdir will keep changing your directory all over the place as you jump to different files throughout your workspace tree. For this reason, I recommend turning off autochdir when using this plugin.
Why not use the vim-rooter plugin?
This looks like a great alternative! I simply didn't need any of the additional capabilities it offers. If you need something with more capabilities, please give vim-rooter a try!
Using vim-plug
Plug 'k3vinw/mwd.vim'
copy autoload/mwd.vim -> ~/.vim/autoload/mwd.vim
copy plugin/mwd.vim -> ~/.vim/plugin/mwd.vim
vim ~/projects/magic # sets Vim's current working directory to ~/projects/magic
vim ~/projects/magic/README.md # sets Vim's current working directory to ~/projects/magic
vim # current working directory is not changed
MIT License. Copyright (c) 2023 Kevin Ray Wood.