Skip to content

Instantly share code, notes, and snippets.

@qnighy
Created September 5, 2009 09:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save qnighy/181353 to your computer and use it in GitHub Desktop.
Save qnighy/181353 to your computer and use it in GitHub Desktop.
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