set backup " keep a backup after owerwriting a file
set backupdir=$HOME/.vim/backupdir
-set undofile " persistent undo history
+set undofile " persistent undo history
set undodir=$HOME/.vim/backupdir
set autowrite " automatically write a file when leaving a modified buffer
\ | wincmd p | diffthis
endif
+" Indent if we're at the beginning of a line. Else, do completion0.
+function! InsertTabWrapper()
+ let col = col('.') - 1
+ if !col || getline('.')[col - 1] !~ '\k'
+ return "\<tab>"
+ else
+ return "\<c-p>"
+endif
+endfunction
+inoremap <tab> <c-r>=InsertTabWrapper()<cr>
+inoremap <s-tab> <c-n>