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=1shows a single-character column; higher values (up to12) 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=0hides the column entirely (default)- Add to your
vimrcwithset foldcolumn=1to always show it - Pairs well with
set foldlevel=99(everything open) so only the gutter reveals fold structure - In Neovim,
foldcolumn=auto:9shows a dynamic column that hides when no folds exist