Hacker News new | ask | show | jobs
by mdup 3917 days ago
I use them all the time (I've switched them on by default in .vimrc) while editing C++ code. Extremely, extremely helpful to get the structure of a file at a glance. For example, if a 400-line file has about 10 functions in it, you can fold all "zM" and instantly you see only the function signatures, while the bodies are folded.

How to enable it: use "set foldmethod=syntax" (with C++) or "set foldmethod=indent" (with JS, where "syntax" doesn't work for me). Also, I use "set foldminlines=0" so that 1-line paragraphs get closed as well (it looks more consistent).

How to use it: close all folds "zM" (I remember it because the M is shaped like it's all folded on itself). Open all folds "zR". Open one fold "zo", close one fold "zc". Open one fold recursively "zO", close one fold recursively "zC".

By the way, I almost never use manual folds, so "zf" is almost useless to me.