I am using Spacemacs to write a program in Clojure. I would like to be able to collapse docstrings. I've tried selecting the docstring and pressing z a
, however, that ends up collapsing the entire function body.
Specifically, I would like to be able to turn this:
(defn flip-and-vectorize
"Returns a vector with the arguments flipped so that
`(flip-and-vectorize 1 2)`
returns the following vector
`[2 1]`"
[a b]
[b a])
into something akin to this
(defn flip-and-vectorize
"..."
[a b]
[b a])
Edit:
Even being able to collapse arbitrary lines would be acceptable; meaning the collapsed version of the above function could look something like this:
(defn flip-and-vectorize
...
[a b]
[b a])
This would mean that the collapsing logic would not need to understand what a "docstring" was, but would merely collapse the selected lines.
There are two options:
Both these packages support folding regions. As in, it can fold whatever is selected. The difference is the latter has more features. Especially the ability to remember folds even if you close and re-open a buffer.
To use them, follow the instructions on their github page. But, when it says to run package-install, instead in spacemacs you want to open your .spacemacs
with SPC f e d
and add the package to your dotspacemacs-additional-packages
as such:
dotspacemacs-additional-packages '(fold-this)
Fold-this is more straightforward to setup, because it has less features.
In either case, you'll need to add your own keybindings. Or just select the region to fold, and go SPC SPC fold-this
.
If using vimish-fold, you need to select the region to fold, and call SPC SPC vimish-fold
to fold, and then you can use C-`
thereafter to toggle the fold on and off. Or call SPC SPC vimish-fold-delete
to remove the fold.
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