Created
November 16, 2012 21:25
-
-
Save graywh/4091066 to your computer and use it in GitHub Desktop.
Insert tabs at beginning of line, spaces afterward
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function! TabOrSpace() | |
let text = strpart(getline('.'), 0, col('.')-1) | |
if text =~ '^\t*$' | |
return "\<C-v>\<Tab>" | |
else | |
let l = strdisplaywidth(text) | |
let n = float2nr(floor(l / &l:softtabstop) + 1) * &l:softtabstop | |
return repeat(' ', n - l) | |
endif | |
endfunction | |
imap <expr> <Tab> TabOrSpace() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment