" blank line so far ? use tab to create ^I : use tab to autocomplete inoremap =InsertTabWrapper('forward') inoremap =InsertTabWrapper('backward') function! InsertTabWrapper(direction) let line = getline('.') " snippets! if exists("*IMAP_Jumpfunc") let snippet = IMAP_Jumpfunc('', 0) if snippet != "" return snippet endif endif " if indenting, indent away if line =~ '^\s*$' return "\" endif " back up to the last whitespace let column = col('.') - 1 while column >= 0 if line[ column ] =~ '\s' let column = column + 1 break endif let column = column - 1 endwhile let current_word = strpart( line, column, col('.') - 1) " looks like a path if current_word =~ '^\~\?\.\?\.\?/' return "\\" " otherwise throw keywords elseif a:direction == "backward" return "\" else return "\" endif endfunction