Right now I am开发者_如何学C using
set autoindent
when I edit Yaml files in Vim, and it works okay by just copying the previous line's indent when you start a new line. I can't help but feel like it could be a little smarter, though. What would be great is if starting a new line after
foo: "bar"
could keep the same indent level, but starting a line after
foo:
would add an additional level of indent.
Xavier inspired me to hack at this a bit, and I came up with my own little indent script for Yaml. It doesn't handle any of the more advanced Yaml features, but it does what I originally asked for.
To use this, you can just drop it into ~/.vim/after/ftplugin/yaml.vim
(assuming you are using set ftplugin on
).
Specific indentation rules are stored on a language basis in :
$VIMRUNTIME\indent\foo.vim
for language foo
.
On my default installation, I have got ruby.vim
, haml.vim
and many other but no yaml.vim
.
You could create an indent\yaml.vim
to get the indentation rules you want. I have quickly tried to search online if something similar was available but I have not find anything.
精彩评论