Skip to content

Instantly share code, notes, and snippets.

@NickCrew
Created December 1, 2018 16:27
Show Gist options
  • Save NickCrew/d079904da560d1ddc8cc39387fead5a5 to your computer and use it in GitHub Desktop.
Save NickCrew/d079904da560d1ddc8cc39387fead5a5 to your computer and use it in GitHub Desktop.
Vim Virtualenv Support
" Add the virtualenv's site-packages to vim path
if has('python')
py << EOF
import os.path
import sys
import vim
if 'VIRTUAL_ENV' in os.environ:
project_base_dir = os.environ['VIRTUAL_ENV']
sys.path.insert(0, project_base_dir)
activate_this = os.path.join(project_base_dir, 'bin/activate_this.py')
execfile(activate_this, dict(__file__=activate_this))
EOF
endif
" Load up virtualenv's vimrc if it exists
if filereadable($VIRTUAL_ENV . '/.vimrc')
source $VIRTUAL_ENV/.vimrc
endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment