Clojure Keybindings
Clojure Logo.
Introduction
In my previous blog post Copilot Keybindings I wrote about my VSCode keybinding configurations with Copilot. In this blog post I shortly list my favorite Clojure programming keybindings.
VSCode + Calva
I use nowadays excellent VSCode Calva extension with Clojure programming. I can really recommend Calva if you use VSCode with other programming languages as well. Calva provides a really good REPL integration, and also other interesting stuff for Clojure programming. I have written three articles regarding my Calva configurations, you might want to read those articles as well:
- Configuring VSCode/Calva for Clojure programming
- Configuring VSCode/Calva for Clojure programming - Part 2
- Configuring VSCode/Calva for Clojure programming - Part 3
My Favorite Clojure Keybindings
I use paredit for structural editing of Clojure code. These are the paredit keybindings that I use the most.
Slurping and barfing (several keybindings). These are the standard paredit features every paredit user uses constantly. I have already mentioned these in my previous blog posts. The Calva paredit documentation explains slurping and barfing well. Another great website to visualize slurping and barfing is The Animated Guide to Paredit.
Raise Sexp (alt+shift+i
). This is also my favorite with Clojure programming. Quite often you realize that you don’t need to apply outer function, just raise the Sexp inside the function.
Evaluate Sexp (alt+l
). Evaluating code in editor is part of the standard REPL workflow. You definitely have to learn that.
Evaluate Current Form (Sexp) to Comment (alt+shift+l
). This is a nice feature. When you are working something, you might want to experiment and save the evaluation result to a comment, so that you can have the result as a visual aid in the comment. Like this:
(interpose 0 [1 2 3])<alt+shift+l here>
;;=> (1 0 2 0 3)
Kill Next Sexp (ctrl+shift+k
). Example: [:a |:b :c]
=> [:a | :c]
. I started programming using Emacs as my editor way back in the 90’s. Therefore, I have used Emacs keybindings in every editor I have used ever since (Eclipse, IntelliJ, and now VSCode). Since ctrl+k
is the kill till the end of line and add to kill ring
Emacs command, it is natural to have a bit similar keybinding for killing Sexps.
Kill All Next Sexps (ctrl+alt+k
). The previous keybinding kills only the next Sexp. This keybinding kills all next Sexps inside this Sexp. Example: [:a |:b :c]
=> [:a |]
.
Copy Sexp (alt+shift+k
). Again, this is a bit similar keybinding, but instead of killing we copy the Sexp. This is actually provided by excellent Joyride which I learned from Clojurians Slack in #calva
channel some years ago.
{
"key": "shift+alt+k",
"command": "joyride.runCode",
"when": "calva:connected && calva:keybindingsEnabled && editorLangId == 'clojure'",
"args": "(p/do (vscode/commands.executeCommand \"paredit.selectForwardSexp\") (vscode/commands.executeCommand \"editor.action.clipboardCopyAction\") (vscode/commands.executeCommand \"cursorUndo\"))"
},
Joyride is an excellent way for a clojurian to extend VSCode functionality. I highly recommend to read more about Joyride.
Show Clojure Documentation for a Symbol (ctrl+alt+d
). I learned this one also from Clojurians Slack in #calva
channel some years ago.
{
"key": "ctrl+alt+d",
"command": "joyride.runUserScript",
"args": "clojuredocs.cljs"
},
The clojuredocs.cljs can be found in the Joyride repo. This is a nice feature. You can browse the Clojure documentation in VSCode without need to open an external web browser. Like this:
In the symbol: ctrl+alt+d
:
=> Simple browser opens the Clojure documentation for the symbol.
Read more about ClojureDocs integration in the Calva User Guide.
Copy Clojure Documentation for a Symbol to a Rich Comment (ctrl+shift+d
). Saves you from opening the documentation, and copy-pasting it manually. This way you can have the documentation in a Rich comment for experimentation.
Some VSCode Spesific Keybindings Used in Programming
These keybindings are not Clojure related, but work with any programming language in my VSCode configuration:
Go to Definition (ctrl+shift+i
). E.g. with Clojure, you can quickly navigate to the function definition. This is actually a great keybinding to learn Clojure standard library functions - look the source code.
Go Back (ctrl+shift+j
). Since I have configured i,j,k,l
as arrow keys (see e.g. Dygma Raise Keyboard Reflections Part 1), if I “go up” to the Symbol using i
= up
, it is logical to go back with j
= left
. Ok, I admit. Logically, it would make more sense to “drill down” to the symbol definition (with k
), but since ctrl+shift+k
is reserved for killing Sexps I had to use i
.
Go Forward (ctrl+shift+l
). I guess you already figured out, why l
(= right
).
Kill Editor Tab (ctrl+x k
). I use this quite often after Show Clojure Documentation for a Symbol, i.e., when I have browsed the documentation, I close the tab with ctrl+x k
.
Next/previous Editor Tab (CapsLock+ctrl+u
/ CapsLock+ctrl+o
). I actually use CapsLock
as a special key, read more about that in my blog Linux Keyboard Configuration with Keyd. Anyway, using these keybindings it is fast to navigate between different editor tabs. I use the same keybingings with Ghostty (see: Linux Configurations for Year 2025) - it is a good general rule to use the same keybingings for similar functionality in different tools.
Show Settings (ctrl+t ctrl+j
). Every once in a while you need to check or configure something in VSCode. It is nice to have a shortcut for VSCode settings.
Show Keybindings (ctrl+t ctrl+k
). For tweaking keybindings, it is also nice to have a keybinding to configure keybindings.
Show Hover Documentation for a Symbol (ctrl+alt+e
). You can see the hover documentation when you place your mouse over the symbol. I prefer not to use mouse, if possible. Therefore I have a keybinding to show the hover documentation. If you want to scroll the hover documentation, you need to give the command twice (i.e., ctrl+alt+e
and again ctrl+alt+e
). To close the hover window, press Esc
. This is a nice feature, since you can have the Clojure documentation in the same editor tab as a hover window, scroll the documentation, and close it - all just using the keyboard. Like this:
Hover documentation.
Help Needed!
There is one issue regarding the above mentioned keybindings that do not work flawlessly with my no-mouse workflow. If I open the Clojure documentation with the ctrl+alt+d
keybinding, I do get the Simple Browser view open, and Joyride script loads the Clojure symbol documentation in Simple Browser. But there are two issues:
- I cannot scroll the web content unless I click using the mouse inside the web content. Only after that the focus is inside the web content, and I can scroll the web page using my keyboard.
- If I have clicked the web content, I cannot close the Simple Browser tab view with my
ctrl+x k
chord, since the web browser consumes all keyboard events. I once again need to use my mouse to close the Simple Browser tab.
This is a bit annoying. If anyone has solved this issue, you can ping me in the Clojurians slack.
Conclusions
As a programmer, it is important to configure your editor to make your workflow as smooth as possible. Therefore, try to figure out logical keybindings for various common functionalities.
And, remember to keep your editor settings in Git!
The writer is working at a major international IT corporation building cloud infrastructures and implementing applications on top of those infrastructures.
Kari Marttila
Kari Marttila’s Home Page in LinkedIn: https://www.linkedin.com/in/karimarttila/