vim settings for YAML files

For editing YAML, be it for OpenShift / Kubernetes or Ansible, having your editor set up right can help to avoid common mistakes. So here is the minimalistic config in my ~/.vimrc to make working with YAML files easier. I am sure there are even more plugins or settings available, but this minimal set of commands works fine for me:

set ts=2
set sts=2
set sw=2
set expandtab

syntax on
filetype indent plugin on

set ruler

Here is a quick explanation of what the settings above actually do:

set ts=2Sets tabstop to 2 for working with YAML
set sts=2“softtabstop” makes spaces feel like tabs
set sw=2Sets the shift width to 2, making shift operations (<< or >>)
set expandtabExpands tabs to spaces
syntax onEnable syntax highlighting
filetype indent plugin onFor certain filetypes, enable automatic indenting
set rulerShow column and line number