public
Last active

Dumb-smart indentation for Yaml

  • Download Gist
yaml.vim
VimL
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
" Vim indent file
" Language: Yaml
" Author: Ian Young
" Get it bundled for pathogen: https://github.com/avakhov/vim-yaml
 
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 lnum = v:lnum - 1
if lnum == 0
return 0
endif
let line = substitute(getline(lnum),'\s\+$','','')
let indent = indent(lnum)
let increase = indent + &sw
if line =~ ':$'
return increase
else
return indent
endif
endfunction
 
" vim:set sw=2:

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.