A Visual Guide to Paredit
What is Paredit?
A portmanteau of “parenthesis” and “editing”, Paredit originated in the Lisp community, but it’s not limited to Lisps. It’s a powerful way of structurally editing code that is often overlooked by popular editors.
Commands
Editing
The most commonly used commands are Slurp Forward and Barf Forward –used for editing code. If you are new to Paredit, consider starting with them!
Slurp Forward
- Keybinding
ctrl+alt+right
- Description
- Move the closing node forward, away from the cursor, past the following node, if any.
📼
🧃⏩ Slurp Forward
Barf Forward
- Keybinding
ctrl+alt+left
- Description
- Move the closing node backward, toward the cursor, past the preceding form.
📼
🤮⏩ Barf Forward
Splice
- Keybinding
ctrl+alt+s
- Description
- Remove the enclosing nodes.
📼
🦠 Splice
Raise
- Keybinding
ctrl+alt+p ctrl+alt+r
- Description
- Replace the enclosing node with the current node.
📼
🪜 Raise
Kill
- Keybinding
ctrl+k
- Description
- Delete the current node.
📼
🗡 Kill
Cut
- Keybinding
ctrl+alt+x
- Description
- Delete and copy the deleted node into the clipboard.
📼
✂️ Cut
Copy
- Keybinding
ctrl+alt+c
- Description
- Copy the current node into the clipboard.
📼
🪞 Copy
Select Current Node
- Keybinding
ctrl+alt+c ctrl+s
- Description
- Select the current node.
📼
🔎 Select Current Node
By default, executing most edit commands will result in a formatting of the doc using whatever formatter is configured for the doc. To toggle this behavior off, execute the
Toggle Autoformat
command.
Strict Mode
This is a very experimental feature aiming to prevent unbalanced nodes by restricting conventional character deletion (see examples below). By default this feature is not enabled, but it can be toggled on using the Toggle Paredit Mode
command.
Delete Backward
- Keybinding
backspace
- Description
- Delete one character backwards, unless it will unbalance a form. Otherwise, moves past the character instead of deleting it. If the node is empty, then it is removed. You can always force backward deletion with
Force Delete Backward
(alt+backspace
).📼
🔥⏪ Delete Backward
Delete Forward
- Keybinding
delete
- Description
- Delete one character forward, unless it will unbalance a form. Otherwise, move past the character instead of deleting it. If the node is empty, then remove it. You can always force forward deletion with
Force Delete Forward
(alt+delete
).📼
🔥⏩ Delete Forward
Navigation
These commands are used to navigate around, but they may not be very intuitive at the moment. They were mainly included so that folks can utilize them in scripts (see Joyride) or build on top of them in other extensions.
Move Cursor Forward
- Keybinding
alt+right
- Description Move the cursor forward to the next sibling node.
🚟⏩ Move Cursor Forward
📼
Move Cursor Backward
- Keybinding
alt+left
- Description Move the cursor backward to the previous sibling node.
🚟⏪ Move Cursor Backward
📼
Move Cursor Up
- Keybinding
ctrl+up
- Description Move the cursor up to the parent node.
🚡⏫ Move Cursor Up
📼
Move Cursor Down
- Keybinding
ctrl+down
- Description Move the cursor down to the first child node.