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

How do I display a visual column showing fold depth and fold markers on the side of the buffer?

Answer

:set foldcolumn=3

Explanation

The foldcolumn option adds a narrow column on the left side of the window that visually represents the fold structure of the file. Each row shows its fold depth, whether it is the opening or closing line of a fold, and whether folds are open or closed — making it easy to understand nested code structure at a glance.

How it works

:set foldcolumn=N sets the width of the fold column to N characters (0–12). The column uses these symbols:

  • - — open fold (this line is inside an open fold)
  • + — closed fold (the entire fold is collapsed here)
  • | — continuation of an outer fold
  • A number — indicates the fold level

In Neovim 0.9+, the fold column uses Unicode symbols ( / ) by default for a cleaner look.

Example

With :set foldcolumn=2 and some nested folds:

- |  function outer() {
| |    function inner() {
| |      return 42
| |    }
-    }
+ {3}  function another() { ... }   ← closed fold

The fold column shows where each fold begins and ends, how many levels deep you are, and which folds are currently closed.

Tips

  • :set foldcolumn=0 disables the fold column entirely (the default)
  • A value of 1 or 2 is usually enough for most code
  • Combine with foldmethod=indent or foldmethod=syntax to automatically generate folds
  • In Neovim, set set foldcolumn=auto to only show the column when folds actually exist

Next

What built-in LSP keymaps does Neovim 0.10+ provide automatically when a language server is attached?