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.
gqi" ?
Thanks @tomd. 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?
gw doesn't move the cursor
Probably the better choice in most cases
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` argTo line up the pipes I visually select the args block and use the Tabularize plugin like this :Tab /|, which I have mapped to just |
You can format in vim with =. Check this out: https://vim.fandom.com/wiki/Format_a_code_block