💾 Archived View for g.codelearn.me › 2018-12-09-vim-folding.gmi captured on 2024-03-21 at 15:16:21. Gemini links have been rewritten to link to archived content
⬅️ Previous capture (2023-01-29)
-=-=-=-=-=-=-
Hi, I didn't use folding functionality previously at all in any other editors, but after I watched
by Greg Hurrell I found this Vim feature super useful.
So to start getting all benefits from Vim folding just add this to your `.vimrc`:
set foldmethod=indent set foldlevelstart=1
What these lines do is:
languages. There are other options though (see `:h fold-methods`)
your files will be folded by default and you have to unfold functions/methods you want to look at. Value `1` in this case means "fold everything and then unfold it back by one level".
So in case you have class defined then this class will be unfolded and fully visible but all methods inside will be folded.
Here is the example:
Here is keybindings to fold/unfold your code:
Folding mechanism is great in Vim, and actually in every other editors, but I never used it mostly because I'm too lazy to fold the code. Since Vim does it for me (`set foldlevelstart=1`) I always have something folded and it's easy to always remember and use this feature.
Try it!