Skip to content
| Marketplace
Sign in
Visual Studio Code>Programming Languages>Tree-sitter Smart SelectNew to Visual Studio Code? Get it now.
Tree-sitter Smart Select

Tree-sitter Smart Select

awesometaro

|
4 installs
| (0) | Free
AST-aware selection expansion powered by Tree-sitter. Enhances VS Code's built-in Expand/Shrink Selection with precise syntax-tree navigation for 16+ languages.
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

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

  1. Place your cursor in any supported file
  2. Use Expand Selection: ⌃⇧⌘→ (macOS) / Shift+Alt+→ (Windows/Linux)
  3. 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

  1. When you trigger Expand Selection, the extension parses your file into a Tree-sitter AST
  2. It finds the smallest AST node at your cursor position
  3. It walks up the tree to the root, building a chain of SelectionRange objects
  4. Extra ranges are inserted for bracket-inner and string-inner content
  5. Parsed trees are cached and incrementally updated on edits for performance

Requirements

  • VS Code 1.75.0 or later

License

MIT

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2026 Microsoft