Created
September 5, 2009 09:01
-
-
Save qnighy/181353 to your computer and use it in GitHub Desktop.
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
if exists("loaded_autots") | |
finish | |
endif | |
function! AutoTS() | |
setlocal ts=8 | |
if search("^\t","nw") > 0 | |
setlocal noexpandtab | |
if search("^ ","nw") > 0 | |
setlocal sts=2 sw=2 | |
elseif search("^ ","nw") > 0 | |
setlocal sts=4 sw=4 | |
elseif search("^ ","nw") > 0 | |
setlocal sts=2 sw=2 | |
else | |
setlocal sts=8 sw=8 | |
endif | |
else | |
if search("^ [^ ]","nw") > 0 | |
setlocal expandtab | |
setlocal sts=2 sw=2 | |
elseif search("^ [^ ]","nw") > 0 | |
setlocal expandtab | |
setlocal sts=4 sw=4 | |
endif | |
endif | |
endfunction | |
augroup autots | |
au! | |
au BufRead * call AutoTS() | |
augroup END |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment