Created
March 12, 2012 16:46
-
-
Save kcollasarundell/2023269 to your computer and use it in GitHub Desktop.
Dumb-smart indentation for Yaml (mirror)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" 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 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: |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment