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 (Qwerty).

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 enter Syntax Node selection mode, then repeat Delete.

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, enter Syntax Node selection mode, then execute Copy, follwed by Paste.

duplicate-node

Notice how comma is added automatically.

2.3 Swap

To swap an AST node, enter Syntax Node selection mode, then active Swap mode, and execute movements such as Left/Right/First/Last/Jump.

3. First-class syntactic navigation

The following selections/movements are first-class:

  1. Select current largest node
  2. Move to next/previous sibling node
  3. Move to first/last sibling node
  4. Expand selection to parent node
  5. Shrink selection to first-child node

4. Multi-cursor

The following example demonstrates how unused imports can be deleted using multiple cursors.

Notice how the commas are removed automatically.

remove-unused-imports

5. Positional Keymaps

See here.