Overview Version History Q & A Rating & Review
Tree-sitter Smart Select
AST-aware selection expansion powered by Tree-sitter . Enhances VS Code's built-in Expand/Shrink Selection with precise syntax-tree navigation.
Features
Syntax-aware selection — Selections follow the actual AST structure, not just text patterns
16+ languages supported out of the box
Bracket-inner ranges — Select content inside brackets before selecting the brackets themselves
String-inner ranges — Select string content before selecting the quotes
Incremental parsing — Efficient re-parsing on document edits via Tree-sitter's edit API
Custom parsers — Add support for additional languages via .wasm parser files
Supported Languages
Language
Language ID
TypeScript
typescript
TSX
typescriptreact
JavaScript
javascript
JSX
javascriptreact
Python
python
Rust
rust
Go
go
C
c
C++
cpp
Java
java
Ruby
ruby
HTML
html
CSS
css
JSON
json
Bash/Shell
shellscript
PHP
php
Usage
Place your cursor in any supported file
Use Expand Selection : ⌃⇧⌘→ (macOS) / Shift+Alt+→ (Windows/Linux)
Use Shrink Selection : ⌃⇧⌘← (macOS) / Shift+Alt+← (Windows/Linux)
The selection will follow the syntax tree structure of your code, expanding to the next meaningful AST node each time.
Extension Settings
Setting
Default
Description
treeSitterSmartSelect.enabledLanguages
All supported
List of VS Code language IDs to enable smart selection for
treeSitterSmartSelect.additionalParsers
{}
Map of language IDs to custom .wasm parser file paths
treeSitterSmartSelect.maxFileSize
1048576 (1 MB)
Maximum file size for Tree-sitter parsing
treeSitterSmartSelect.includeAnonymousNodes
false
Include anonymous nodes (punctuation) in the selection chain
Adding Custom Language Support
You can add support for additional languages by providing a path to a Tree-sitter .wasm parser file:
{
"treeSitterSmartSelect.additionalParsers": {
"lua": "/path/to/tree-sitter-lua.wasm"
}
}
How It Works
When you trigger Expand Selection, the extension parses your file into a Tree-sitter AST
It finds the smallest AST node at your cursor position
It walks up the tree to the root, building a chain of SelectionRange objects
Extra ranges are inserted for bracket-inner and string-inner content
Parsed trees are cached and incrementally updated on edits for performance
Requirements
License
MIT