DevOps Bootcamp · Lesson

nindent vs indent in Practice

Inserting blocks at the correct indentation level.

Lesson 3 of 413 steps

nindent vs indent in Practice is a free DevOps Bootcamp lesson on CoddyKit. This is lesson 3 of 4. Any 3 lessons of this learning path are free to read in full — after that, CoddyKit PRO unlocks every lesson, plus hands-on practice with a built-in code editor and a 24/7 AI tutor. It is part of the DevOps Bootcamp learning path, and your progress syncs across the web and the CoddyKit app. The DevOps Bootcamp course includes 4 lessons in total.

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. 🧹

Free to start

Learn DevOps Bootcamp with an AI tutor — free

Write and run real code in your browser, get instant help from a 24/7 AI tutor, and pick up where you left off on the web or in the app.

Courses
142
Lessons
568

Frequently Asked Questions

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

Yes — any 3 lessons of the DevOps Bootcamp learning path, including “nindent vs indent in Practice”, are free to read in full here on the web. After that, CoddyKit PRO unlocks every lesson, plus interactive practice with a built-in code editor and a 24/7 AI tutor. The DevOps Bootcamp course includes 4 lessons in total.

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

Inserting blocks at the correct indentation level. You practise DevOps Bootcamp 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 DevOps Bootcamp?

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

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 DevOps Bootcamp lesson?

Yes. Every DevOps Bootcamp 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 DevOps Bootcamp