Reputation: 141080
A code is over 2000 lines full of folds. I select a certain block in Visual mode to which I would like to start writing. However, things around the block, such as folds, hinder my writing, and I accidentally tend to modify them. Currently, I avoid such mistakes by writing the block in a separate vim. It is not a real solution, and it gets awkward with too many vim's open.
How can I hide everything except the block in folds?
Upvotes: 9
Views: 2321
Reputation: 13238
You can do zMzv
or zMzO
.
zM
closes all folds
zv
makes the current line visible
zO
opens all folds under cursor recursively up to root
(O
in zO
is the uppercase "oh" character, not zero 0
)
Upvotes: 19
Reputation: 47567
Not exactly what you asked for, but might work...
Map this friend to something:
:vnoremap <Leader>za <Esc>`<kzfgg`>jzfG`<
I have it on leader => z (because it has to do w/ folding) => a (because it stands for "around")
Usage:
Select lines with V, hit leader z a.
Everything above and below will be folded.
Upvotes: 9