Question

A code is over 2 000 lines full of folds. I select a certain block in Visual mode to which I would like to start writing. However, things around, such as folds, hinter 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 VIMs open. How can I hide everything except the block in folds?

Was it helpful?

Solution

You can do zMzv or zMzO.

zM closes all folds, zv makes current line visible and zO opens all folds under cursor recursively up to root.

OTHER TIPS

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top