You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
23 lines
372 B
23 lines
372 B
2 years ago
|
function! Indent_level(lnum)
|
||
|
return indent(a:lnum) / &shiftwidth
|
||
|
endfunction
|
||
|
|
||
|
function! Fold(lnum)
|
||
|
let l:c = Indent_level(a:lnum)
|
||
|
let l:n = Indent_level(a:lnum + 1)
|
||
|
let l:p = Indent_level(a:lnum - 1)
|
||
|
|
||
|
if l:n > l:c
|
||
|
return '>' . l:n
|
||
|
endif
|
||
|
|
||
|
if l:n < l:c
|
||
|
return '<' . l:c
|
||
|
endif
|
||
|
|
||
|
return l:c
|
||
|
endfunction
|
||
|
|
||
|
setlocal foldmethod=expr
|
||
|
setlocal foldexpr=Fold(v:lnum)
|