Wrong indentation when editing Yaml in Vim

前端 未结 7 1134
一整个雨季
一整个雨季 2021-01-30 03:50

Vim does not seem to correctly react at a dash symbol in YAML files therefore breaking the format.

For example I have a block which should look like this:



        
7条回答
  •  长发绾君心
    2021-01-30 04:14

    I've found https://github.com/stephpy/vim-yaml to work great. It's a vim plugin that does indentation (and syntax highlighting) of yaml files. Installing it solves the specific problem that you've asked about too.

    You need to install the plugin (see the doco in the GitHub repo) and as long as your filetype=yaml it'll correct your indenting. It'll help you both

    1. as you're typing the snippet you've provided, or
    2. if you already have some yaml written, you can select it (with V for line-wise selection then use j or k to select more lines) then trigger the vim formatting with =

提交回复
热议问题