The NrrwRgn plugin (the plugin page has links to alternative plugins) comes closest to your use case: As it mirrors part of the buffer into a separate scratch buffer (and can sync it back to the original), you can treat it like any regular Vim buffer, and edit away without worries.
There are other workarounds, like
- folding other lines (what you've discovered)
- using syntax highlighting (to the
Normal group, or maybe
NonText) or the conceal feature to make the contents invisible (whereas folding only works on whole lines, this works best on columns)
However, the hidden fragments are still there, so searches and other commands like
:substitute will still find them, so the illusion is far from perfect and you have to be vigilant during editing.
The best out of the box solution that I can imagine is a set of
:autocmds that move the uninteresting lines into buffer-local List variable(s) on
BufReadPost,BufWritePost and undo that on
BufWritePre. That way, the lines would only be there during saving.