Wednesday, June 28, 2006
Vim documentation: fold
Folding code is a way of collapsing certain sections so you don't have to look at them all the time. For instance, the code that I'm working in has tons of case statements, so it's often helpful to bury the code under some statements so I can see how cases far apart compare to each other. The command for folding from a { to a } is: v%zf
v - visual mode
% - mark to matching { or }
zf - fold, baby, fold
How to preserve folds? That's the challenge. It's supposed to be incorporated into the vim syntax file, but I have only found a few syntax files that have them (python being one of them). I think I'd have to write a macro to do it right. The problem, of course, is that it's metadata, so you have to store it somewhere. You could, possibly, store it in the file under some kind of comment header, but that leads to obvious problems of integrity. The other way is to designate a place (%vimdir%/meta) to store it for each file.
I will not be embarking upon writing anything like this anytime soon. I'm convinced that someone out there already has it set up.
Comments:
<< Home
Duh! Exactly 60 seconds after writing that, I read the very top of the fold documentation, which states:
The manual folds are lost when you abandon the file. To save the folds use the |:mkview| command. The view can be restored later with |:loadview|.
Post a Comment
The manual folds are lost when you abandon the file. To save the folds use the |:mkview| command. The view can be restored later with |:loadview|.
<< Home