This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-12-05
Channels
- # adventofcode (111)
- # announcements (20)
- # babashka (19)
- # beginners (47)
- # calva (7)
- # clojure (56)
- # clojure-dev (27)
- # clojurescript (2)
- # events (1)
- # holy-lambda (1)
- # juxt (2)
- # meander (18)
- # minecraft (4)
- # missionary (107)
- # nextjournal (21)
- # off-topic (30)
- # reagent (7)
- # reitit (19)
- # releases (1)
- # tools-build (8)
- # tools-deps (7)
- # vim (22)
- # xtdb (4)
What is your favorite way to comment out a form?
I have a castom binding that prepends reader macro to a form. (i#_<ESC>
parenthesesis navigates to begining of the form (mapping from vim-sexp plugin), i
enters insert mode, #_
just types the reader macro and esc back to normal
Simple and efficient. We could also have a keybinding for commenting out the top level form [[i#_<ESC>
.
What key binding do you use for that?
Do you have also a key binding to uncomment a form?
<leader>cu
which finds previous reader macro and deletes it <Cmd>let s=@/<CR>l?\\v(#_)+<CR>dgn:let @/=s<CR>
all the complications here are to avoid poluting search register (stores value of search register in register s and then restores back)
Could you explain the meaning of l?
and dgn
?
And what is \\v(#_)+
?
\v
is some sort of modifier in vim to say how to treat the rest of patter, it makes it more like regular expressions. Otherswise vim has different rules, that I don't remember
Why do you need two backslashes then
OK. Thank you for your tips
Do you still use this bindings or may be found a solution to toggle — to commnen/uncomment with one binding, like gcc? I started a new https://clojurians.slack.com/archives/C0DF8R51A/p1651008804660709, and there is an idea of making it a part of lsp-refactor
By the way, my new solution is to use vim-surround (it's a fennel code, but the mappings should be obvious):
(set nvim.g.surround_99 "#_\r")
(util.buffer-map :n :<Leader>c :ysafc {:noremap false})
With this the code get autoformated:
(defn level-up [hero]
(-> hero
(update :level inc)
(update :health + 5)))
(defn level-up [hero]
#_(-> hero
(update :level inc)
(update :health + 5)))