Reputation: 31481
In a large PHP application, I would like to collapse all the code blocks inside my current block, but not the current block itself. For instance:
if ($something) {
if ($another) {
// some code;
}
| <--THIS IS MY CURRENT CURSOR POSITION
if ($yetAnother) {
// more code;
}
if ($stillAnother) {
// yet more code;
}
}
How can I collapse the three inner if
s but not the outer if
?
Thanks!
Upvotes: 3
Views: 3876
Reputation: 28944
If I got the question right, the change in folding described in the statement is equivalent to the following sequence of actions.
The mapping
:nnoremap <silent> <leader>f m`zcVzCzo``
consequently runs the commands corresponding to the aforementioned steps, saving the cursor position before accomplishing them, and restoring it after.
Upvotes: 2
Reputation: 7981
The closest thing I can come up with is zMzv. That will close all folds (zM) and then open just enough folds to view the line your cursor is on (zv). You can map that to a shorter command if necessary.
It's not exactly what you asked for, since it will close all folds outside of your outer if
statement as well.
Upvotes: 3
Reputation: 16185
See if this works:
:set foldmethod=marker foldmarker={,} foldlevel=2
Upvotes: 8