aboutsummaryrefslogtreecommitdiff
path: root/vim/autoload/indent.vim
diff options
context:
space:
mode:
Diffstat (limited to 'vim/autoload/indent.vim')
-rw-r--r--vim/autoload/indent.vim32
1 files changed, 32 insertions, 0 deletions
diff --git a/vim/autoload/indent.vim b/vim/autoload/indent.vim
new file mode 100644
index 00000000..3e850c63
--- /dev/null
+++ b/vim/autoload/indent.vim
@@ -0,0 +1,32 @@
+function! indent#spaces(...) abort
+ setlocal expandtab
+ let &l:shiftwidth = a:0
+ \ ? a:1
+ \ : 0
+ let &l:softtabstop = has#('patch-7.3.693')
+ \ ? -1
+ \ : &l:shiftwidth
+ call indent#undo()
+endfunction
+
+function! indent#tabs() abort
+ setlocal noexpandtab shiftwidth< softtabstop<
+ call indent#undo()
+endfunction
+
+function! indent#undo() abort
+ if exists('b:undo_indent_set')
+ return
+ endif
+ let l:undo = 'call indent#reset()'
+ if exists('b:undo_indent')
+ let b:undo_indent .= '|'.l:undo
+ else
+ let b:undo_indent = l:undo
+ endif
+ let b:undo_indent_set = 1
+endfunction
+
+function! indent#reset() abort
+ setlocal expandtab< shiftwidth< softtabstop< tabstop<
+endfunction