Language features
Development reference · View source
| Key | Action |
|---|---|
Space l h | Show documentation for the symbol under the cursor |
Space l s / Space l S | Document / workspace symbols |
Space l d | Diagnostics |
Space l r / Space l a | Rename symbol / apply a code action |
Space l c | Ask for completions (Ctrl-x in Insert mode) |
Space l f / Space l R / Space l ? | Format / restart language servers / report language-server state |
Space l g d/D/y/r/i | Definition / declaration / type definition / references / implementation |
gd / gD | Go to definition / declaration |
gy / gi | Go to type definition / implementation |
gr | Go to references |
:format | Format the buffer (typed equivalent of Space l f) |
Tab | Code actions for the selection |
Hover documentation stays anchored to its source.
- A short document is a peek: it closes and passes the next key on.
- With more than twelve lines, the title says how much was left out, and Enter
opens the full text in a retained read-only
[documentation]buffer.
Goto and pickers. One result moves the selection to it; several open a
picker. Every picker filters as you type, moves with the arrows or
Ctrl-n/Ctrl-p, opens with Enter, and closes with Escape.
Undo. A completion that needs an import applies both edits as one undo step, and so does a rename across a file. Everything typed between entering Insert mode and returning to Normal is one undo step too; undo and redo map the caret through the inverse edit rather than leaving it at a stale offset.
Completion
Three sources share one popup:
| Source | Appears | Needs |
|---|---|---|
| Language server | After one of the server’s trigger characters, on Ctrl-x, or with Space l c | A server |
| Path | When the text before the caret is a valid directory followed by part of a name | Nothing |
| Word | When a typed prefix reaches editor.word_completion_minimum characters (3) | Nothing |
| Key | Effect |
|---|---|
Tab | Accept |
Escape | Dismiss |
| Enter | Always inserts a newline and dismisses the popup |
Why Enter never accepts. A popup can open on its own, after a trigger character or any three-character word prefix, so Enter always keeps its usual meaning rather than risking an unwanted candidate on a keystroke meant to end a line.
Escape dismisses the popup and returns to Normal mode in one press for
automatic word completion, and in an editable explorer, where a row’s / can
open path completion unasked.
Language-server completion:
- An explicit
Ctrl-xincludes the identifier already before the caret, uses the server’sfilterTextandsortTextwhen present, and stays the active source until space, newline, acceptance, or dismissal. - Typing punctuation does not hand the session to word or path completion. A trigger character refreshes the candidates for the new context.
- If the prefix has no matches, the popup hides without ending the session, so Backspace can bring matches back. Backspace and Delete keep the session; moving the caret or another editing command ends it.
Ctrl-xreplaces a word popup as soon as the request is sent.
Path completion:
- It opens on any keystroke that leaves a valid directory plus a name
fragment before the caret, not only on
/, so editing an existing path shows hints just like typing a new one. - Relative paths resolve against both the active file’s parent and the
project root, so
dir/,files/,./files/, and../files/work from whichever makes them valid. - Directories keep a trailing
/; accepting one offers its children. - A large directory shows its first few hundred names, but typing more narrows against the whole directory, so every existing name is reachable.
- A path in progress takes over from word completion as soon as
/is typed, unless an explicit LSP session is active. - Command palette path arguments work the same way.
Word completion offers words from every open buffer in the workspace, including the one being edited.
- Every open buffer contributes, including explorers, whose entries are file names.
- It appears in file buffers, the scratch buffer, and the commit message.
- A word is Unicode letters and numbers. A hyphen stays inside only when it
joins characters on both sides, so
up-to-datestays whole. Other punctuation is a boundary and never included. - Words from the current buffer come first, ordered by how often they occur there, then words from every other buffer in the same order. The word being typed is never offered to complete itself.
- A background index keeps the list, so a candidate can be one keystroke stale, but typing never waits for it.
- It never overrides
Ctrl-xor a path in progress. - Turn it off, or change the trigger length, with
editor.word_completionandeditor.word_completion_minimuminSpace o o.