Actions
Keymap
Notes for reading
- When "selection" is mentioned, you should read it as "selection(s)", because these actions work with multiple cursors.
Search
← Search
/Search →
Open search prompt.
This
Search this selection.
Modifications
Raise
This is one of my favorite actions, it only works for syntax node selection modes.
This replaces the parent node of the current node, with the current node.
Note: Raise should never cause any syntax errors, if it does that's a bug.
← Replace
/Replace →
Replace current selection with previous/next copied text in the clipboard history.
This is similar to Yanking Earlier Kills in Emacs.
This is useful when you want to retrieve earlier copies.
← Open
/Open →
Open before/after selection.
If the current selection mode is not Syntax Node, then Open inserts a newline with the respective indent after/before the current line.
Otherwise, it inserts a gap before/after the current selection, and then enter Insert mode.
← Delete
/Delete →
Delete until previous/next selection.
This deletes the current selection(s), however, if the current selection mode is contiguous, it will delete until the next/previous selection, and selects the next/previous selection.
But, if the current selection is the last/first selection, it will delete until the previous/next selection instead, and selects the previous/next selection.
For example, consider the following Javascript code:
hello(x, y);
Assuming the current selection mode is Syntax Node, and the current selection is x
, pressing d
results in the following:
hello(y);
Change
This deletes the current selected text, and enter Insert mode.
Replace #
Replace with pattern.
This replaces the current selection using the search pattern and replacement pattern specified in the Text Search Configuration.
For example:
Mode | Selected text | Search | Replacement | Result |
---|---|---|---|---|
Literal | f | f | g | g(x) |
Regex | "yo" | "(.*)" | [$1] | [yo] |
AST Grep | f(x) | f($Z) | $Z(f) | x(f) |
Naming Convention Agnostic | a_bu | a bu | to li | to_li |
Join
Joins multiple lines within the current selection(s) into a single line.
Break
Break the current selection(s) to the next line, with the indentation of the current line.
This is a shortcut of i enter esc
.
Dedent
/Indent
Dedent/Indent the current selection by 4 spaces.
Transform
Transformative actions are nested under here, such as (non-exhaustive):
w
: Wrap (Wrap current selection into multiple lines)l
: Convert tolower case
s
: Convert tosnake_case
Meta
← Insert
/Insert →
Enter insert mode before/after selection.
Mark
Toggles a bookmark at the current selection, allowing you to navigate elsewhere in the codebase while maintaining a reference to your focal point without memorizing its exact location.
Undo
/Redo
Notes:
- Undo/redo works for multi-cursors as well
- The current implementation is naive, it undoes/redoes character-by-character, instead of chunk-by-chunk, so it can be mildly frustrating
Save
Keybinding: enter
Upon saving, formatting will be applied if possible.
After formatting, the Current movement will be executed, to reduce disorientation caused by the misplaced selection due to content changes.
Clipboard
There are two kinds of clipboards:
- The editor clipboard
- The system clipboard
By default, the editor clipboard is used, to use the system clipboard, press
space
before pressing the keybindings of the following actions.
The editor clipboard works for multiple cursors, the text of each cursor can be copied to and pasted from the editor clipboard respectively.
The system clipboard however does not support multiple cursors. When there are multiple cursors:
- Copy joins every selection into a single string and then place it in the system clipboard
- Paste uses the same string from the system clipboard for every cursor
Note: when new content are copied to the system clipboard, it will also be copied to the editor clipboard.
Copy
This action copies the current selected text.
Copy behaves differently depending on the number of cursors.
When there is more than one cursor, the selected texts of each cursor will be copied to the cursor-specific clipboard.
Paste ←
/Paste →
Paste before/after selection.
This action pastes the content from the clipboard (either the system clipboard or cursor-specific clipboard) after/before the current selection.
Notes:
- It does not replace the current selection.
- The pasted text will be selected.
Smart Paste
Smart Paste will be executed when the selection mode is contiguous.
Smart Paste works by analyzing the gap between the current selection and the previous/next selection, then insert the gap before/after the pasted text.
For example, consider the following Javascript code:
hello(x, y);
Assuming the current selection mode is Syntax Node, and the current selection is y
, and the
copied text is z
, performing a p
results in the following:
hello(x, y, z);
Change X
This is similar to Change, but it copies the deleted text into the system clipboard.
Like ctrl+x
in Windows and cmd+x
in macOS.
Replace
This replaces the current selected text with the copied text.
Replace X
Replace Cut, swaps the current selection with the content in the clipboard.