Skip to content

Editing code

Tyrn is a native editor with language server support, multiple cursors and syntax-aware selection. This page covers the editing commands you reach for every day. Keybindings are shown in the cmd-shift-p style and can be changed in Key bindings.

Selections and cursors

Task Keybinding
Select all cmd-a
Select the current line cmd-l
Expand selection to the enclosing syntax node ctrl-shift-right or cmd-ctrl-right
Shrink selection ctrl-shift-left or cmd-ctrl-left
Undo the last selection change cmd-u
Redo the selection change cmd-shift-u

Multiple cursors

Add cursors to edit several places at once.

  • Hold alt and click to add a cursor. The modifier is set by multi_cursor_modifier ("alt" by default, or "cmd_or_ctrl").
  • cmd-d selects the next occurrence of the word under the cursor. Press it again to add the next one.
  • ctrl-cmd-d does the same going backwards.
  • cmd-shift-l selects every occurrence in the buffer.
  • cmd-ctrl-p and cmd-ctrl-n add a cursor above or below. cmd-alt-up and cmd-alt-down do the same while skipping soft-wrapped lines.
  • cmd-k cmd-d moves the latest selection to the next match instead of adding one.

Press escape to collapse back to a single cursor.

Moving and changing lines

Task Keybinding
Move line up or down alt-up, alt-down
Duplicate line up or down alt-shift-up, alt-shift-down
Delete line cmd-shift-k
Join lines ctrl-j
Insert line below or above cmd-enter, cmd-shift-enter
Indent or outdent cmd-], cmd-[
Toggle line comment cmd-/
Toggle block comment cmd-k cmd-/
Delete to start or end of line cmd-backspace, cmd-delete
Rewrap comment or selection cmd-k q

cmd-k q rewraps text at preferred_line_length. By default it only rewraps inside comments. Change that with allow_rewrap ("in_comments", "in_selections" or "anywhere").

Folding

Task Keybinding
Fold or unfold the current block cmd-k cmd-l
Fold alt-cmd-[
Unfold alt-cmd-]
Fold all cmd-k cmd-0
Unfold all cmd-k cmd-j
Fold at level 1 to 9 cmd-k cmd-1 to cmd-k cmd-9

Formatting and code actions

  • cmd-shift-i formats the buffer.
  • alt-shift-o organizes imports.
  • cmd-. opens code actions at the cursor.
  • f2 renames the symbol under the cursor through the language server.

To format on save, set format_on_save to "on". See Configuring languages for formatter choices.

settings.json
{
"format_on_save": "on",
"remove_trailing_whitespace_on_save": true,
"ensure_final_newline_on_save": true
}

Typing aids

These are on by default. Turn any of them off in settings.

Setting Default What it does
use_autoclose true Types the closing bracket or quote for you
use_auto_surround true Typing a bracket or quote with text selected wraps the text
auto_indent "syntax_aware" Indents new lines using the syntax tree. Also "preserve_indent" and "none"
auto_indent_on_paste true Re-indents pasted code to fit
linked_edits true Editing an opening HTML tag edits the closing tag too, when the language server supports it
extend_comment_on_newline true Continues a comment on the next line
jsx_tag_auto_close.enabled true Closes JSX tags as you type

Whitespace, wrapping and line numbers

  • cmd-k z toggles soft wrap for the buffer. The default soft_wrap is "none".
  • cmd-; toggles line numbers.
  • show_whitespaces is "selection" by default. Other values are "none", "all", "boundary" and "trailing".
  • tab_size is 4 and hard_tabs is false by default, and both can be set per language. See Configuring languages.

Hover, signature help and inlay hints

  • cmd-k cmd-i shows hover information. cmd-i shows signature help.
  • Inlay hints are off until you set inlay_hints.enabled to true. ctrl-: toggles them for the current editor.
  • auto_signature_help shows method signatures while you type inside parentheses (false by default).

AI help while you edit