I use (Mac)Vim in my projects set to use 2 spaces for tabs and even have a script which converts all tabs to 2 spaces on save.
When I work with other developers though, sometimes they use tabs instead of spaces and I am looking for a quick way to switch two different vim configurations, would love to switch them on the command line, like this
macvim --oh-no-not-tabs-again .
What’s the best practice on this?
You can have autocommands fired on a per-directory basis, so you can configure anything you want automatically without hotkeys. Here’s what I came up with:
This configures vim to automatically figure out when you’re in a subtree of /path/to/csharp/files and sets the buffer-local variables the way you want. Put it in your .vimrc and you’re good to go.
Edit Here’s some code to put in your .vimrc that searches up the tree for the nearest “local” .vimrc and sources (loads) it. Use with caution! Don’t set globals or do anything “interesting”, you’ll get hard-to-diagnose behaviors. I have not exhaustively tested it. It might eat your children. You have been warned!
I’m sure 10 years from now I’ll find some already-existing built-in way to do it in one line.