This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-03-02
Channels
- # announcements (25)
- # babashka (76)
- # beginners (74)
- # biff (36)
- # calva (11)
- # cider (5)
- # clerk (43)
- # cljs-dev (4)
- # cljsrn (12)
- # clojure (111)
- # clojure-austin (14)
- # clojure-europe (82)
- # clojure-nl (2)
- # clojure-norway (5)
- # clojure-uk (1)
- # clojurescript (36)
- # core-async (13)
- # cursive (30)
- # datomic (12)
- # fulcro (6)
- # honeysql (9)
- # hyperfiddle (73)
- # instaparse (3)
- # introduce-yourself (1)
- # membrane (40)
- # nbb (2)
- # off-topic (6)
- # other-languages (9)
- # polylith (33)
- # reagent (2)
- # reitit (7)
- # rum (7)
- # shadow-cljs (47)
- # tools-deps (10)
- # vim (11)
- # xtdb (16)
I'm kind of embarrassed to ask this, but ... what tool/keymapping do you use to reformat docstrings? i.e. one edits a docstring, and now some lines are too long or too short, and you have to reformat the docstring paragraph: what tool do you use to do that automatically? What's embarrassing is that I've been using Clojure for years, and I still don't have a convenient way to do this! 🤷 I think I must just have missed something--because obviously everyone has to do it often--and I've never come across a keybinding or utility that does it. (Currently, I temporarily add empty lines above and below the docstring, and then use a standard paragraph formatter, and then remove the empty lines. Which is silly. I can make a vim macro out of these steps, but that seems silly, too. Because surely it's already been done.) I'm using conjure, but perhaps it's normally done using some other tool. I don't see anything in the Conjure docs.
Thanks @UE1N3HAJH. The i"
piece isn't working for me, but I understand the idea. I'll have to figure out what's going on with my config. (I see now that part of the reason I never learned this trick is that (a) I write text more often than code, (b) I started using vim so long ago that g
and q
were not mapped to anything--or not to anything I thought useful--so I created my own custom mappings for them for use with writing text [and got annoyed when Bram or someone created standard mappings later] so I've never used g
or q
in the usual way. Oh well.)
I tend to use gw
for this (e.g. gwi"
, or gww
to just do the current line)
I forget the difference between gw
and gq
-- does anyone here know?
I just visually select the paragraph I want to format and hit gq
(that stopped working recently, though. Glad to learn that gw
does the trick)
I tend to document function args in a little block like this:
foo | Doco for the `foo` arg
bar | Doco for the `bar` arg
To line up the pipes I visually select the args block and use the Tabularize plugin like this :Tab /|
, which I have mapped to just |
Thanks @U0AHJUHJN, @U0DTSCAUU, @UE1N3HAJH. That's all very helpful. Now I just have to figure out my preferred approach (and mess with my config a little to create a new mapping because my fingers have permanently reassigned the meaning of g
to something no one else uses).
You can format in vim with =
. Check this out: https://vim.fandom.com/wiki/Format_a_code_block