Quick text selection sidekick
Quickly select text inside or outside the closest/innermost pair of quotes (' " `), brackets (<> {} [] ()), or HTML/XML/JSX tags (<div>...</div>); switch quote styles; and rename a tag pair's name at both ends together — all from the keyboard.
Commands & default keybindings
In the Command Palette every command is listed under the PK Smart Selection category — type pk to see them all.
| Command |
Windows/Linux |
macOS |
| Select Inside Quote |
Ctrl+' |
Cmd+' |
| Select Outside Quote |
Ctrl+Shift+' |
Cmd+Shift+' |
Switch Quote Style (' → " → ` → …) |
Ctrl+Alt+' |
Cmd+Alt+' |
| Select Inside Bracket |
Ctrl+9 |
Cmd+9 |
| Select Outside Bracket |
Ctrl+Shift+9 |
Cmd+Shift+9 |
| Select Inside Quote, Bracket, or Tag (innermost of any) |
Alt+' |
Alt+' |
| Select Outside Quote, Bracket, or Tag (innermost of any) |
Alt+Shift+' |
Alt+Shift+' |
| Shrink Selection (step back one select/expand) |
Ctrl+Alt+9 |
Cmd+Alt+9 |
| Select Inside Tag (HTML/XML/JSX content) |
Alt+. |
Alt+. |
| Select Outside Tag (includes both tags) |
Alt+Shift+. |
Alt+Shift+. |
| Select Tag Name (both ends, type to rename together) |
Ctrl+Alt+. |
Cmd+Alt+. |
Behavior
- Inside selects between the delimiters; Outside includes them.
- The innermost pair enclosing the cursor wins; with no enclosing pair, the nearest pair on the line is used (forward first).
- Press again to expand to the next enclosing pair:
f(a, g(b|, c), d) → (b, c) → (a, g(b, c), d).
- Shrink Selection steps back through the select/expand history one step at a time. Moving the cursor by any other means (mouse, arrow keys, typing) clears the history.
- Switch Quote Style re-escapes as needed (
'it\'s' → "it's") in a single undo step.
- All commands support multiple cursors (each cursor independently).
- Escaped quotes (
\') are never delimiters, using the escape character of the language: a back tick in PowerShell, none in Batch, ini/properties and plain text — so cd "C:\path\to\dir\" still selects the path there, while "a\"b" stays one string in C/JS/Python (see smartSelection.escapeCharacter).
- Angled brackets use heuristics so
a < b is not a pair but List<Dict<str, int>> is (enabled per language, see settings).
- Tag commands find the innermost enclosing HTML/XML/JSX open/close tag pair (mismatch-tolerant, ignores self-closing tags and HTML void elements like
<br>). Enabled by default in html, xml, vue, javascriptreact, typescriptreact, and svelte files (see smartSelection.tagLanguages). Select Tag Name selects the tag name at both the opening and closing tag simultaneously, so typing a new name renames both ends together in one step.
- Select Inside/Outside Quote or Bracket or Tag (
Alt+' / Alt+Shift+') also considers tag pairs in languages where smartSelection.tagLanguages applies, so e.g. <div>print("hel|lo")</div> expands hello → "hello" → ("hello") → print("hello") on repeated invocation. In languages without tag support it behaves exactly as before (quote/bracket only).
Customizing keybindings
All commands are standard VS Code commands — remap them in File → Preferences → Keyboard Shortcuts, or in keybindings.json:
{ "key": "alt+b", "command": "smartSelection.selectInsideBracket", "when": "editorTextFocus" },
{ "key": "ctrl+9", "command": "-smartSelection.selectInsideBracket" } // remove default
Settings
All settings below are grouped under PK Smart Selection in the VS Code Settings UI (search @ext:PrasertKana.quick-text-selection-sidekick or type PK Smart Selection).
| Setting |
Default |
Description |
smartSelection.quoteCharacters |
["'", "\"", "`"] |
Characters treated as quotes |
smartSelection.switchQuoteCycle |
["'", "\"", "`"] |
Cycle order for Switch Quote Style |
smartSelection.escapeCharacter |
"auto" |
Character escaping a quote inside a string: auto / \ / ` / none |
smartSelection.multiLineStrings |
true |
Back-tick strings may span lines |
smartSelection.angleBrackets |
"auto" |
<...> matching: auto / always / never |
smartSelection.angleBracketLanguages |
TS, C#, C++, Java, Rust, HTML, … |
Languages where auto enables <...> |
smartSelection.expandOnRepeat |
true |
Repeat invocation expands outward |
smartSelection.showNoMatchHint |
false |
Status-bar hint when nothing matches |
smartSelection.ignoreDelimitersInComments |
true |
Ignore comments: skip brackets in them, and never pair a quote across a comment boundary |
smartSelection.tagLanguages |
HTML, XML, Vue, JSX, TSX, Svelte |
Languages where tag commands are active |
Most settings can also be overridden per language in settings.json — for example, to
stop repeated presses from expanding in Python only:
"[python]": { "smartSelection.expandOnRepeat": false }
angleBracketLanguages, tagLanguages, and showNoMatchHint are global — the first two
are themselves lists of languages, so a per-language override would be meaningless.
Known limitations (v1)
- String/comment detection is heuristic (no language-server tokens); block comments are not masked (HTML comments are masked for tag matching specifically).
- Comments are their own scope for quote matching: an apostrophe in prose (
# Prasert's profile) can no longer pair with code outside the comment, and a string inside a comment stays selectable. Within a single comment an apostrophe can still pair with a later quote (# Prasert's 'note'), and comment detection is heuristic — one line-comment token and one block-comment pair per language.
- Tag matching is regex-based, not a full HTML/XML parser: JSX fragments (
<>...</>) are not matched, and pathologically malformed markup may not match as expected.
Remote repositories
The extension supports text files opened through VS Code Remote - SSH, WSL,
Dev Containers, Codespaces, and desktop virtual workspaces such as Remote
Repositories. Install the extension in the location offered by VS Code, then
use its commands and keybindings normally.
Selection commands also work in read-only virtual repositories. Switch Quote
Style requires a writable document.
The browser-only editors at vscode.dev and github.dev are not currently
supported; this package provides a desktop extension host entry point.
Contributing / development
See DEV.md for build, test, and release instructions.
| |