Code Folding in Emacs

This week I learned Emacs has code folding built in (of course it has!). It's called Hide Show and you enable it with hs-minor-mode and toggle function, class or comment folding/unfolding with hs-cycle. There's many other commands to try: hs-hide-all, hd-show-all and so on.

emacs code folding

The default bindings look pretty wild, like C-c @ C-s, but you know what? For the most part, I've stopped learning new shortcuts the last ten years or so and just use M-x with fuzzy search. Works well enough for me, even for things I use regularly, like eglot-rename and delete-trailing-white-space.

Using smex ensures I always have the last recently used at the top.

Happy folding!


~ /home 🏠 ~ talks 💬 ~ bash ~ craftsmanship ~ db ~ dongxi ~ emacs ~ escenic ~ iam ~ java ~ js ~ language ~ latex ~ ldap ~ life ~ linux ~ llm ~ mac-os-x ~ mt-foo ~ network ~ norsk ~ python ~ quotes ~ running ~ security ~ travel ~ unix ~ various ~ vcs ~ webdesign ~ windows ~ discoveries ~ cv 🧙 ~

Licensed under CC BY Creative Commons License ~ 📡 RSS feed ~ ✉ torstein.k.johansen @ gmail ~ 🐘 @skybert@hachyderm.io ~ 🎥 youtube.com/@skybert