I have to read a few giant Perl scripts, and I would like to know how do you guys add the "minimizing" brackets functionality in Vim as GUI text editors do. I'm having a tough time understanding the code because of this, If I could just minimize those giant if, functions, etc... my mind would be very grateful.
Mappings to toggle folds With the following in your vimrc, you can toggle folds open/closed by pressing F9. In addition, if you have :set foldmethod=manual , you can visually select some lines, then press F9 to create a fold.
Vim uses the same movement commands to define folds. Folding also works in visual mode. If you enter visual mode using v or V , then select a few lines of text using the movement keys, and type zf , Vim will create a fold comprising those lines. Another option is to specify a range in command mode.
To delete all fold markers, visually select all the file with ggVG before doing a zd .
The problem is that when you close Vim, your artfully folded code returns to its unfolded state. The solution is quite simple - when you are ready to save your folds run the :mkview command. This will save your folds in the current buffer to your viewdir ( :h viewdir ) depending on your environment.
By minimizing, I suppose you are referring to code "folding"
:help fold
zC closes all folds recursively under the cursor, zc closes a single fold. zo opens a single fold under the cursor, while zR recursively opens all folds.
See also
:help :foldmethod
For Perl, you will want :set foldmethod=syntax
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With