commit fea8aa11e559210eb308f6e2af30533bdf606368
parent 098ff05f3f8bf2a895082222057bc4dac2482703
Author: Anders Damsgaard <andersd@riseup.net>
Date: Wed, 7 Feb 2018 14:40:11 -0500
Add yaml configuration for Vim
Diffstat:
1 file changed, 23 insertions(+), 0 deletions(-)
diff --git a/links/.vim/ftplugin/yaml.vim b/links/.vim/ftplugin/yaml.vim
@@ -0,0 +1,23 @@
+augroup yaml_config
+
+ " Inspired by Ian Young's script
+ 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
+
+augroup END