]> git.phdru.name Git - dotfiles.git/blobdiff - .vimrc
.vimrc: keep undo history across sessions by storing it in a file
[dotfiles.git] / .vimrc
diff --git a/.vimrc b/.vimrc
index bc4a54ab55e9fae8ac9c1916511d3d184a35ed3e..745587a5e393214248f73fe86e1bf5a61a42bc26 100644 (file)
--- a/.vimrc
+++ b/.vimrc
@@ -129,7 +129,7 @@ endif
 if has("win32")
    set directory=$TEMP//,c:/tmp//,c:/temp//
 else
-   set directory=~/tmp//,/var/tmp//,/tmp//
+   set directory=~/tmp/vim//,~/tmp//,/var/tmp//,/tmp//
 endif
 " if a directory ends in two path separators "//"
 " or "\\", the swap file name will be built from the complete path to
@@ -144,6 +144,15 @@ set wildignore+=*.py[co] " Ignore these patterns when completing file names
 set wildmenu      " command-line completion shows a list of matches
 set wildmode=longest,list:longest,full " Bash-vim completion behavior
 
+" Keep undo history across sessions by storing it in a file
+if has('persistent_undo')
+    let myUndoDir = expand('$HOME/tmp/vim/undo')
+    " Create dirs
+    call system('mkdir -p ' . myUndoDir)
+    let &undodir = myUndoDir
+    set undofile
+endif
+
 " 22 executing external commands
 
 if has("filterpipe")
@@ -271,6 +280,8 @@ autocmd BufWritePost ~/.vimrc source ~/.vimrc | syntax on
 if version >= 700
 " Save all files before running any quickfix command (grep, makeprg, etc.)
 autocmd QuickFixCmdPre * wall
+" automatically close quickfix if it's the only window left
+autocmd WinEnter * if winnr('$') == 1 && &buftype == "quickfix" | quit | endif
 endif
 
 " Syntax highlighting
@@ -525,6 +536,19 @@ if exists("$SLOWTERM")
 endif
 
 
+if has("python")
+python << END_OF_PYTHON
+import sys, os
+
+virtualenv_dir = os.environ.get('VIRTUAL_ENV')
+if virtualenv_dir:
+    sys.path.insert(0, virtualenv_dir)
+    activate_this = os.path.join(virtualenv_dir, 'bin', 'activate_this.py')
+    execfile(activate_this, dict(__file__=activate_this))
+END_OF_PYTHON
+endif
+
+
 " ----------
 " From http://slobin.pp.ru/vim/_vimrc.html