Vim folding

Hi, I didn't use folding functionality previously at all in any other editors, but after I watched

=> this awesome video

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!

Proxy Information
Original URL
gemini://g.codelearn.me/2018-12-09-vim-folding.gmi
Status Code
Success (20)
Meta
text/gemini
Capsule Response Time
442.529697 milliseconds
Gemini-to-HTML Time
0.435209 milliseconds

This content has been proxied by September (ba2dc).