Skip to main content

Why Ki?

The following are reasons that prevented me from escaping the Ki island, although the sirens of the Copilots were irresistible.

No land in the archipelago of the modal editors has more economic keybindings for these actions.

1. First-class syntactic selection

Being first-class means that it is not an extra or even sidekick; it is the protagonist.

To select the largest syntax node under the cursor, simply press s (Syntax Node).

This feature is handy if you ever asked this question:

"How can I select the current expression/function/argument/statement?"

And this works as long as your language is blessed by the Tree-sitter grammarians.

select-largest-node

2. First-class syntactic modification

2.1 Deletion

To delete multiple sibling syntax nodes in a row, first press s, then repeat d.

delete-node

Notice the comma between the current and the next node is also deleted.

This doesn't only work for JSON, it can be used to also delete statements, array elements, arguments, and basically anything within a list of syntax nodes.

2.2 Duplication

To duplicate an AST node, press s, then y (Copy), and then p (Paste).

duplicate-node

Notice how comma is added automatically.

2.3 Swap

To swap an AST node, press s, then x (Exchange mode), and press l(Next) or h` (Previous).

swap-node

3. First-class syntactic navigation

To navigate the syntax tree, press s, then press any of the following keys:

  • h (Previous sibling)
  • l (Next sibling)
  • , (First sibling)
  • . (Last sibling)
  • j (First child)
  • k (Parent)

node-navigation

4. Multi-cursor

Delete unused imports:

  • ] h (set selection mode to Diagnostics Hint)
  • q (enter multi-cursor mode)
  • l (add a cursor to the next selection)
  • s (set selection mode to Syntax Node)
  • d (delete)
  • space o (keep only the primary selection)

Again, notice how the commas are removed automatically.

remove-unused-imports