Skip to content

Instantly share code, notes, and snippets.

@erikcorry
Created December 9, 2014 14:33
Show Gist options
  • Save erikcorry/d5c1474f5954130a2b4b to your computer and use it in GitHub Desktop.
Save erikcorry/d5c1474f5954130a2b4b to your computer and use it in GitHub Desktop.
" Tab completion in vim using the tab key.
" Turns into two spaces if there is no alphanumerics on the left of the cursor.
function! CleverTab()
if strpart( getline('.'), col('.')-2, 1) =~ '^\s*$'
return " "
else
return "\<C-P>"
endfunction
inoremap <Tab> <C-R>=CleverTab()<CR>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment