Back to tips

Extend Selection to Syntax Nodes

Select to syntax node boundaries for precise code selection

navigation intermediate February 5, 2026 · godruoyi
#selection #editing #navigation

Use syntax node selection commands to extend your selection to the start or end of larger syntax nodes, making it easy to select complete code structures precisely.

Available Commands

Two new commands extend selections to syntax boundaries:

  • editor: select to start of larger syntax node - Extend selection backward to syntax node start
  • editor: select to end of larger syntax node - Extend selection forward to syntax node end

These complement the existing move to {start,end} of larger syntax node commands, but extend selections instead of moving the cursor.

How to Use

  1. Place cursor in your code
  2. Run one of the selection commands via command palette
  3. Selection extends to the nearest syntax node boundary
  4. Repeat to expand to larger nodes

Setup Keybindings

Add to your keymap.json:

{
  "context": "Editor",
  "bindings": {
    "alt-shift-[": "editor::SelectToStartOfLargerSyntaxNode",
    "alt-shift-]": "editor::SelectToEndOfLargerSyntaxNode"
  }
}

Why This Matters

Precise selection: Select exactly to code structure boundaries (functions, blocks, expressions).

Structural editing: Work with code semantically rather than by lines or words.

Emacs-like workflow: Similar to Emacs mark-sexp for S-expression selection.

Perfect for structural code refactoring and editing operations that need to respect syntax boundaries.