A Visual Studio Code extension that provides format support for YAML language.
You find the right format extension if you come from DevOps world, e.g., Kubernetes, Ansible Playbooks or CI workflow like Github Actions and so on.
We all love Emojis, and yes, it has builtin support!
#Features
As a Kubernetes developer, aka YAML engineer, you deal with a lot of yaml files everyday. Take the k8s yaml for example:
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment
spec:
selector:
matchLabels:
app: nginx
replicas: 2
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx:1.14.2
ports:
- containerPort: 80
As you see, the sequence style(containers
and ports
) in the k8s style yaml has no indent. Each time you play with kubectl, there is no indent. Not to mention some tool like kustomize requires you do that.
Unluckily, the builtin yaml format has its own option philosophy. It always does indent and resists to accept such a customization setting.
It's useless. I have to keep the style manually every time editing yaml files, or you will end up with a non-idiomatic one.
It's tedious. So I create this extension to make life easier. Now you can control which way you prefer and everyone is happy.
Enjoy!
#Extension Settings
This extension contributes the following settings:
kubernetes-yaml-formatter.compactSequenceIndent
: Enable compact sequence indent, i.e. no indent (defaulttrue
).kubernetes-yaml-formatter.includeDocumentStart
: Include---
at document start (defaultfalse
).
It makes format yaml on save default to true
, you can disable it:
"[yaml]": {
"editor.formatOnSave": false
}