- commit
- f2445a75172e024a46050b28ea760a0ef296426b
- parent
- 77b5902b37c7e11e1ecbd78dc57dce12daadcdab
- Author
- Tobias Bengfort <tobias.bengfort@gmx.net>
- Date
- 2016-09-11 23:12
add SetIndent function
Diffstat
| M | plugin/detectindent.vim | 24 | ++++++++++++++---------- |
1 files changed, 14 insertions, 10 deletions
diff --git a/plugin/detectindent.vim b/plugin/detectindent.vim
@@ -1,7 +1,11 @@1 -1 set tabstop=22 -1 set softtabstop=23 -1 set shiftwidth=24 -1 set noexpandtab-1 1 function! SetIndent(expand, width) -1 2 let &l:expandtab = a:expand -1 3 let &l:tabstop = a:width -1 4 let &l:shiftwidth = a:width -1 5 let &l:softtabstop = a:width -1 6 endfunction -1 7 -1 8 call SetIndent(0, 2) 5 9 6 10 function! MatchIndent() 7 11 let n = 1 @@ -10,13 +14,13 @@ function! MatchIndent() 10 14 let cur_line = getline(n) 11 15 12 16 if cur_line =~ '^ '13 -1 set ts=2 sw=2 sts=2 noet-1 17 call SetIndent(0, 2) 14 18 return 15 19 elseif cur_line =~ '^ '16 -1 set ts=4 sw=4 sts=4 et-1 20 call SetIndent(1, 4) 17 21 return 18 22 elseif cur_line =~ '^ '19 -1 set ts=2 sw=2 sts=2 et-1 23 call SetIndent(1, 2) 20 24 return 21 25 endif 22 26 @@ -24,8 +28,8 @@ function! MatchIndent() 24 28 endwhile 25 29 endfunction 26 3027 -1 command! Tabs set ts=2 sw=2 sts=2 noet28 -1 command! Spaces set ts=4 sw=4 sts=4 et29 -1 command! Spaces2 set ts=2 sw=2 sts=2 et-1 31 command! Tabs call SetIndent(0, 2) -1 32 command! Spaces call SetIndent(1, 4) -1 33 command! Spaces2 call SetIndent(1, 2) 30 34 31 35 autocmd BufNewFile,BufRead * call MatchIndent()