From: Samir Benmendil Date: Wed, 16 Oct 2013 17:28:33 +0000 (+0200) Subject: smart tab (completion + indent) X-Git-Url: https://git.rmz.io/dotfiles.git/commitdiff_plain/8bc36a1369024837a862421a6467bd9336a28070?ds=inline smart tab (completion + indent) --- diff --git a/vimrc b/vimrc index 77ebad0..ceab90e 100644 --- a/vimrc +++ b/vimrc @@ -159,7 +159,7 @@ set writebackup " write a backup file before overwriting a file 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 @@ -228,3 +228,14 @@ if !exists(":DiffOrig") \ | 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 "\" + else + return "\" +endif +endfunction +inoremap =InsertTabWrapper() +inoremap