Permalink
Browse files

Create set-indent plugin

  • Loading branch information...
nelstrom committed Jan 21, 2012
1 parent e574b12 commit 3f1ef022f97c5a232d802cf42ecda7258718e039
Showing with 28 additions and 28 deletions.
  1. +28 −0 vim/plugin/set-indent.vim
  2. +0 −28 vimrc
View
@@ -0,0 +1,28 @@
+" Set tabstop, softtabstop and shiftwidth to the same value
+" From http://vimcasts.org/episodes/tabs-and-spaces/
+command! -nargs=* Stab call Stab()
+function! Stab()
+ let l:tabstop = 1 * input('set tabstop = softtabstop = shiftwidth = ')
+ if l:tabstop > 0
+ let &l:sts = l:tabstop
+ let &l:ts = l:tabstop
+ let &l:sw = l:tabstop
+ endif
+ call SummarizeTabs()
+endfunction
+
+function! SummarizeTabs()
+ try
+ echohl ModeMsg
+ echon 'tabstop='.&l:ts
+ echon ' shiftwidth='.&l:sw
+ echon ' softtabstop='.&l:sts
+ if &l:et
+ echon ' expandtab'
+ else
+ echon ' noexpandtab'
+ end
+ finally
+ echohl None
+ endtry
+endfunction
View
28 vimrc
@@ -136,34 +136,6 @@ function! <SID>SynStack()
echo map(synstack(line('.'), col('.')), 'synIDattr(v:val, "name")')
endfunc
-" Set tabstop, softtabstop and shiftwidth to the same value {{{2
-" From http://vimcasts.org/episodes/tabs-and-spaces/
-command! -nargs=* Stab call Stab()
-function! Stab()
- let l:tabstop = 1 * input('set tabstop = softtabstop = shiftwidth = ')
- if l:tabstop > 0
- let &l:sts = l:tabstop
- let &l:ts = l:tabstop
- let &l:sw = l:tabstop
- endif
- call SummarizeTabs()
-endfunction
-
-function! SummarizeTabs()
- try
- echohl ModeMsg
- echon 'tabstop='.&l:ts
- echon ' shiftwidth='.&l:sw
- echon ' softtabstop='.&l:sts
- if &l:et
- echon ' expandtab'
- else
- echon ' noexpandtab'
- end
- finally
- echohl None
- endtry
-endfunction
" Strip trailing whitespaces {{{2
function! Preserve(command)

0 comments on commit 3f1ef02

Please sign in to comment.