How do I create a fold that spans the current paragraph in manual fold mode?
Answer
zfap
Explanation
Combining the fold-creation operator zf with the ap (around paragraph) text object gives you a quick way to collapse any paragraph into a single fold line. This is faster than counting line numbers or entering visual mode just to create a fold.
How it works
zfis the fold-creation operator — it works with any motion or text objectapis the "around paragraph" text object, selecting the current paragraph including its trailing blank line- Together,
zfapfolds the entire paragraph the cursor is in - Requires
set foldmethod=manual(or usingexpr/markermethods that accept manual folds)
Example
With the cursor inside a prose paragraph or a code block separated by blank lines:
Before:
This is the first line of a long
paragraph that goes on for several
lines and would benefit from folding.
After zfap:
+-- 3 lines: This is the first line... ---
The fold is created instantly without entering visual mode.
Tips
zfip(inner paragraph) excludes the trailing blank line — use when you want the blank line visiblezf{motion}works with any motion:zf5jfolds 5 lines down,zf/end<CR>folds to the next occurrence of "end"zddeletes the fold at the cursor;zDdeletes recursivelyzatoggles the fold open/closed;zMcloses all folds in the file- Store folds with
:mkviewand restore them with:loadview