Conditionally Sourcing vimrc files

March 16, 2008 at 07:28 PM | Uncategorized | View Comments

I'm sitting in a tutorial at PyCon1 on hacking the Python core. One of the things that was mentioned is Python's coding standards, and their supporting Vim scripts.

I've got no complaints with them -- I just don't want to use them all the time. So I've added this bit of code to ~/.vimrc:

let path = expand('%:p:h')
if path =~ "Python-trunk"
    let path = substitute(path, '\(.*/Python-trunk\).*', '\1', '')
    execute('source ' . path . '/Misc/Vim/vimrc')
endif

In short, if it looks like I'm in the Python-trunk directory, it sources their vimrc :-)

1: Blog posts to come... I promise!