Indent and fold in Vim with zo and zc

Part of my guide of vim tips/snippets

How to fold/unfold lines, and indenting in Vim

Auto indention with ==

  • Press == to auto indent the current line (or current selection)

Open/close fold with zo

  • A fold can be a block, everything within things such as { and } etc.
  • Open a ‘fold’ with zo (lowercase)
  • Close the fold (minimize it) on the current line with zc

If you want to close all folds or open all folds:

  • Close all folds in document with zC
  • and open all folds in the document with zO

Moving around to the next fold

  • Use zj to move down to the next fold
Part of my guide of vim tips/snippets