vimfolding

VIM folds for Everything except Something


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?


Solution

  • 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)