Key Bindings for Clojure

I like programming (at work) and learning for fun. You'll often find me cooking and working on my house in my spare time.
Search for a command to run...

I like programming (at work) and learning for fun. You'll often find me cooking and working on my house in my spare time.
No comments yet. Be the first to comment.
I have a credit card that offers cash back on purchases. Credit cards provide a time buffer between when a charge is incurred and when funds leave the checking account paying it off. This helps avoid

I want to get into the Kotlin community to accelerate my learning. Where should I go? Well, this was handy, https://kotlinlang.org/community/. I went through each of these resources. Unless stated oth

We're switching from Clojure to Kotlin at work. Is that good? I don't know yet! Here are some things I love about Clojure: its incredible REPL EDN keywords maps with heterogeneous keys and values

I've been using Arc Browser for a long time. Why? Because I love vertical tabs in my browser. They allow me to read more of each tab's title when I have a lot of tabs. What Are Vertical Tabs? Tabs are

Imagine rows of letters, numbers, and Greek letters: [[:a :b] [:1 :2] [:alpha :beta]] Now, you want to transpose them. You started with a vector of vectors. Clojure's map function is pretty amazing

When I write Clojure, I use VS Code and Calva on a Mac and I try to avoid RSI. Everything I do in VS Code is accessible via the Command Palette, Cmd+Shift+P or F1. However, keyboard shortcuts are sure nice. I execute some commands frequently, and these commands would benefit the most from keyboard shortcuts. There are only so many reasonable shortcuts and my memory is only so good, so I want a system that benefits from mnemonics. This reminds me of this standup routine, Gary Gulman On How The States Got Their Abbreviations (warning, a little inappropriate!).
The default Calva keybindings for Paredit can be found here, https://calva.io/paredit/. Not everything we'll discuss is for Paredit. Let's begin. I'll say the Command Title, the keybinding, and some commentary. To change keybindings, in the Command Palette, either run
Preferences: Open Keyboard Shortcuts or
find the specific command you want to run and select the gear icon.
Calva: Load/Evaluate Current File and its Requires/Dependencies.
I bound that to Option+V.
Calva: Evaluate Current Form (or selection, if any)
I left that as Ctrl+Enter. This one is pretty obvious - evaluate the thing next to my cursor.
Calva: Evaluate Top Level Form (defun)
I left this as Option+Enter. That may have been the default. When might I use this? Anytime my cursor isn't at the opening or closing of a form. Example: I make a change to a function and want to evaluate it:
; Start with this
(defn greet
[]
(println "hello"))
; I'm using | to indicate where my cursor is.
; Then I eval the top level form
(defn greet
[]
(println "hi|"))
Calva Paredit: Raise Sexp
Option+R. Raise is awesome.
; Here's the starting point. Again, | is my cursor.
; So I don't want the try/catch anymore.
(try
|(println "Did")
(catch Exception _
(println "Tried")))
; raise!
(println "Did")
Calva Paredit: Slurp Sexp Forward
Ctrl+Option+Right
(+ 1|) 2
; slurp forward!
(+ 1 2)
Calva Paredit: Splice Sexp
Option+S
(+ 1 (|2))
(+ 1 2)
Calva Paredit: Wrap Around ()
Option+P
random-uuid|
(random-uuid)
Calva Paredit: Wrap Around [] and Calva Paredit: Wrap Around {}
I don't use these nearly as much as (), so I left the defaults - Ctrl+Shift+Option+S/C.
Calva: Run Current Test
Command+T
Calva: Run Tests for Current Namespace
Option+Command+T
Calva Paredit: Convolute Sexp ¯\_(ツ)_/¯
Ctrl+Option+C. What does Convolute do? This:
(:a
(:b
|(:c)))
(:b
(:a
(:c)))
When would someone do that?
(deftest my-test
(let [a true] ; I want to move this inside the testing form
(testing "a"
|(is (true? a)))))
(deftest my-test
(testing "a"
(let [a true]
(is (true? a)))))