开发者

How do I get great auto indenting with Vim and Yaml?

开发者 https://www.devze.com 2023-02-08 05:40 出处:网络
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 i

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消