How do I get Vim to automatically load .vimrc config from the current directory?

If 'exrc' is set, the current directory is searched for a file named _vimrc, .vimrc or _exrc at startup. This is not done every time you :cd to a new directory. See

:help .vimrc

Here's something you could try:

autocmd BufEnter{,other event} {full path to file} {do blah}

And you would put that into an auto command group:

augroup {name you want here}
    autocmd!
    autocmd BufEnter{,other event} {full path to file} source {full path to vimrc file}
    autocmd BufEnter{,other event} {full path to file} {define mapping here}
    autocmd BufEnter{,other event} {full path to file} {do blah}
    autocmd BufEnter{,other event} {full path to file} {do blah}
augroup END

So you would put your settings here, this way if you're in a specific buffer those mappings will load.

I also recommend doing some BufLeave events in order to unset those mappings when you're not in those buffers, if you want.

would that work for your needs? I'm not sure exactly of what you need so I simply made a template for you. :)

As I showed, you can do it in various ways, you decide which is better for your needs. Sorry I'm not actually solving the underlying problem of that setting not working though. :(


Just for the record, what I ended up doing was creating a shortcut for each of my projects and loading a project specific config file as a session file using -S session.vim.

Tags:

Vim

Gvim