Extend Selection to Syntax Nodes
Select to syntax node boundaries for precise code selection
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 starteditor: 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
- Place cursor in your code
- Run one of the selection commands via command palette
- Selection extends to the nearest syntax node boundary
- 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.