Code foldingλ︎
Code folding allows you to collapse a code block onto one line, allowing you to see more of your code in the window. A code block for Clojure includes comments, def
, defn
and the threading macros ->
and -->
.
Overview of a namespace
z m shows just the names of all function definitions and vars in a namespace, providing a quick way to review all namespace api.
Keybindingsλ︎
Evil state | Description |
---|---|
z a | Toggle fold for current code block |
z c | Folds a code block |
z m | Folds all code in buffer |
z o | Opens current folded code block |
z O | Opens current folded code block recursively |
z r | Opens all folded code blocks in the buffer |
Code Fold Transient Stateλ︎
Space z opens a transient state for folding code, most useful when reviewing code.
Code folding methodsλ︎
There are two code folding methods, evil folding (the default) and origami. Evil fold is recommended for Clojure development.
Origami adds a recursive open and close and what it calls an org-mode header collapse (didn't seem to work on Clojure code). Origami seems less useful for Clojure than evil-fold, as folding seems to only work at the top level.
Origami allows you to write your own parser to teach different ways to fold code. Origami is a great choice if you want to customise your code folding.
Switching to origami code foldingλ︎
Space f e d to open the Spacemacs configuration file
Space s s dotspacemacs-folding-method
to find the code folding setting, Enter to end the search.
Change the code folding method: dotspacemacs-folding-method 'origami
Space q r to restarting Emacs and download the origami package.