aboutsummaryrefslogtreecommitdiff
path: root/vim/autoload/indent.vim
blob: 3e850c6396e0a8b37dd6481e0c08d43e9b9ef9d8 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
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