-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathyaml.vim
More file actions
37 lines (31 loc) · 754 Bytes
/
yaml.vim
File metadata and controls
37 lines (31 loc) · 754 Bytes
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
33
34
35
36
37
" Vim indent file
" Language: Yaml
" Author: Ian Young
if exists("b:did_indent")
finish
endif
"runtime! indent/ruby.vim
"unlet! b:did_indent
let b:did_indent = 1
setlocal autoindent sw=2 et
setlocal indentexpr=GetYamlIndent()
setlocal indentkeys=o,O,*<Return>,!^F
function! GetYamlIndent()
let prevlnum = v:lnum - 1
if prevlnum == 0
return 0
endif
let line = substitute(getline(v:lnum),'\s\+$','','')
let prevline = substitute(getline(prevlnum),'\s\+$','','')
let indent = indent(prevlnum)
let increase = indent + &sw
let decrease = indent - &sw
if prevline =~ ':$'
return increase
elseif prevline =~ '^\s\+\-' && line =~ '^\s\+[^-]\+:'
return decrease
else
return indent
endif
endfunction
" vim:set sw=2: