0Pricing
Helm Academy · Lesson

nindent vs indent in Practice

Inserting blocks at the correct indentation level.

nindent vs indent in Practice is a free Helm Academy lesson on CoddyKit — lesson 3 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Helm Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.

Indentation Matters in YAML

YAML uses spaces to show structure, so a block inserted at the wrong depth breaks the file. Helm gives you helpers to indent output correctly.

What indent Does

The indent function adds a fixed number of spaces to the start of every line in a string, shifting a whole block to the right.

{{ .Values.config | indent 4 }}

It Does Not Add a Newline

Here is the catch: indent shifts every line but does not add a leading newline. The first line lands right where the action sits.

Enter nindent

The nindent function does the same spacing but first prints a newline, so the block starts cleanly on its own fresh line.

data:
  {{ .Values.config | nindent 4 }}

Why the n Saves You

That leading newline from nindent means you do not have to leave a trailing space and guess alignment after a key on the same line.

The Most Common Case

You will reach for nindent most when pairing a toYaml block under a key, since it places the rendered map neatly below the key.

resources:
  {{ toYaml .Values.resources | nindent 4 }}

Count From the Key

Pick the number by counting spaces from the parent key, not from column zero. A child two levels deep usually needs nindent 4.

When indent Still Fits

Plain indent is right when the block already begins on its own line, so you do not want an extra newline pushed in front of it.

Mind the Off-by-Two

Most YAML nesting steps by two spaces. Getting the nindent count wrong by two is the top cause of a chart that fails to parse.

Verify by Rendering

Never guess the depth. Run helm template and read the raw output to confirm the inserted block lines up under its parent key.

helm template ./mychart | less

Both Take a Pipe

Both helpers read the string from the pipe on their left, so they pair naturally with toYaml to format a whole map into your manifest.

Quick Check

You write {{ toYaml .Values.env | indent 4 }} right after a key on the same line and the YAML is malformed.

Recap

You now know indent spaces a block, nindent adds a newline first, and rendering is the surest way to confirm the depth. 🧹

Frequently asked questions

Is the “nindent vs indent in Practice” lesson free?

Yes — the full text of “nindent vs indent in Practice” is free to read here on the web, and the Helm Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Helm Academy course, upgrade to CoddyKit PRO.

What will I learn in “nindent vs indent in Practice”?

Inserting blocks at the correct indentation level. You practise Helm Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.

Do I need any experience to start Helm Academy?

No prior experience is required. Helm Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 3 of 4, so you can start here or from the beginning and move at your own pace.

How long does the “nindent vs indent in Practice” lesson take?

Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.

Can I write and run code in this Helm Academy lesson?

Yes. Every Helm Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.

All lessons in this course

  1. Assigning Template Variables
  2. Preserving the Root Dot Inside range
  3. nindent vs indent in Practice
  4. Debugging Rendered Whitespace
← Back to Helm Academy