Search code examples
intellij-ideayamlkubernetes-helm

Configure IntelliJ reformat for double curly braces in yaml


YAML files sometimes contain templated values in double curly braces, e.g. when used by Helm to configure Kubernetes:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: {{ .Release.Name }}
  namespace: {{ .Release.Namespace }}

The formatting as I have shown it is what I want, and what is standard in Helm files: a space within the inner pair of curly braces, but not between the two curly braces on each side.

Is it possible to configure IntelliJ to respect this formatting style? As far as I can tell, the options (under File > Settings > Editor > Code Style > YAML > Spaces) are either:

  • Within code braces YES, which would produce { { .Release.Name } }
  • Within code braces NO, which would produce {{.Release.Name}}

Solution

  • If someone ends up here like me, this is solved by installing the following two plugins from JetBrains:

    After installing, the auto formatting respected the following style without further configurations:

    apiVersion: apps/v1
    kind: Deployment
    metadata:
      name: {{ .Release.Name }}
      namespace: {{ .Release.Namespace }}