vimtricks.wiki Concise Vim tricks, one at a time.

How do I show a visual fold depth indicator in the Vim gutter?

Answer

:set foldcolumn=1

Explanation

Setting foldcolumn to a non-zero value adds a narrow column on the left side of each window that visually represents the fold structure of your file. This makes it easy to see which lines are inside folds and how deeply nested they are — without opening the folds themselves.

How it works

  • foldcolumn=1 shows a single-character column; higher values (up to 12) show more nesting detail
  • The column uses these symbols:
    • - — a closed fold whose start is on this line
    • | — the interior of an open fold
    • + — the start of an open fold (when combined with nesting indicators)
    • A digit — the nesting depth when folds are deeply nested
  • Clicking in the foldcolumn (with mouse enabled) opens or closes the fold
  • Use foldcolumn=auto (Neovim) to only show the column when folds actually exist

Example

:set foldmethod=indent
:set foldcolumn=2

With a Python file, the gutter might look like:

  def outer():     ← open fold, depth 1
| def inner():    ← open fold, depth 2
||    pass
- class Foo:      ← closed fold

Tips

  • foldcolumn=0 hides the column entirely (default)
  • Add to your vimrc with set foldcolumn=1 to always show it
  • Pairs well with set foldlevel=99 (everything open) so only the gutter reveals fold structure
  • In Neovim, foldcolumn=auto:9 shows a dynamic column that hides when no folds exist

Next

How do I quit Vim without saving using a two-keystroke normal mode shortcut?