Skip to content

Instantly share code, notes, and snippets.

@leif81
Created January 24, 2013 03:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save leif81/4617337 to your computer and use it in GitHub Desktop.
Save leif81/4617337 to your computer and use it in GitHub Desktop.
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
endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment