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
altand click to add a cursor. The modifier is set bymulti_cursor_modifier("alt"by default, or"cmd_or_ctrl"). cmd-dselects the next occurrence of the word under the cursor. Press it again to add the next one.ctrl-cmd-ddoes the same going backwards.cmd-shift-lselects every occurrence in the buffer.cmd-ctrl-pandcmd-ctrl-nadd a cursor above or below.cmd-alt-upandcmd-alt-downdo the same while skipping soft-wrapped lines.cmd-k cmd-dmoves 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-iformats the buffer.alt-shift-oorganizes imports.cmd-.opens code actions at the cursor.f2renames 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.
{ "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 ztoggles soft wrap for the buffer. The defaultsoft_wrapis"none".cmd-;toggles line numbers.show_whitespacesis"selection"by default. Other values are"none","all","boundary"and"trailing".tab_sizeis4andhard_tabsisfalseby default, and both can be set per language. See Configuring languages.
Hover, signature help and inlay hints
cmd-k cmd-ishows hover information.cmd-ishows signature help.- Inlay hints are off until you set
inlay_hints.enabledtotrue.ctrl-:toggles them for the current editor. auto_signature_helpshows method signatures while you type inside parentheses (falseby default).
AI help while you edit
- Inline suggestions as you type come from Autocomplete.
- Explain, Rewrite Selection (
ctrl-enter) and Generate commit message use a harness you choose. See Explain, rewrite and commit.