Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Keep a project specific .vimrc at the root of your git project repo (e.g. ~/workspace/myproject/.vimrc) and have it sourced when you launch vim from anywhere in your project dir tree. This only works with git repos because we rely on git for determining our project root dir. Put the content of this in your ~/.vimrc
" Source a vimrc from git project root
let project_root = system("git rev-parse --show-toplevel")
" System commands seem to have a trailing newline, so lets get rid of that
let chomped_project_root = project_root[:-2]
let project_vimrc = chomped_project_root."/.vimrc"
if filereadable(project_vimrc)
execute "source" project_vimrc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.