Copy Auto — Smart Selection
A VS Code extension (runs in Cursor too) that predicts the text you're
trying to select and expands your selection to it in one keystroke.
Demo scenario
you want to copy the url from the below line
const sunriseImage = "https://images.unsplash.com/photo-1642019247215-639093b12ded?auto=format&fit=crop&w=1600&q=80"
- Start selecting
https://im as usual.
- After ~120 ms, the remaining URL is ghost-highlighted and the status bar shows
url (+97 chars).
- Press Option+Enter (⌥↩) — the whole URL is now selected & copied (copying can be turned off in settings:
copyAuto.autoCopy).
No config, no network, works offline.
Usage
- Start any small selection. Supported by M1 heuristics:
- URLs —
https://…, www.…
- Quoted strings —
"…", '…', …
- Balanced brackets —
(...), [...], {...} (multi-line)
- Words / identifiers / paths
- Confirm with Option+Enter (
copy-auto.acceptSuggestion), via the status-bar
button, or Command Palette.
- Dismiss: clear the selection (Esc) or switch editor/document.
Requirements
For Users
- VS Code or Cursor (no additional tools required)
For Developers
- Node.js >= 18, npm
- Cursor or VS Code (+ dev tools for F5 debugging)
Develop
npm install
npm test # vitest — heuristic engines
npm run compile # tsc -> out/
F5 # Extension Development Host with the extension live
Settings
| Setting |
Default |
Meaning |
copyAuto.enabled |
true |
master switch |
copyAuto.maxChars |
80 |
max current-selection size to suggest for |
copyAuto.autoCopy |
true |
copy to clipboard on accept |
copyAuto.showStatusBarHint |
true |
status-bar hint visibility |
copyAuto.chip |
inline |
near-text chip: inline (no layout shift), codelens (clickable, shifts lines), none |
copyAuto.engine |
auto |
auto·heuristic·llm (LLM planned) |
Change the confirm key in Settings → Keyboard Shortcuts →
search Copy Auto.
Package & install
# If you want to create your own VSIX package:
npm install -g vsce # one-time setup
vsce package # → copy-auto-0.1.7.vsix
Install via Extensions → "Install from VSIX…".
Project structure
src/
extension.ts # wiring: commands, lifecycle
settings.ts # copyAuto.* configuration wrapper
selectionWatcher.ts # debounced selection changes → engine → UI
prediction/engine.ts # vscode-aware adapter (keeps anchor, builds Selection)
prediction/heuristics.ts# PURE text matchers (unit-tested, no vscode import)
prediction/heuristics.test.ts
ui/highlight.ts # ghost-highlight decoration + status-bar hint + context key
Status / roadmap
- M1 (this build): offline heuristics, ghost highlight, Option+Enter accept.
- M2 (planned): optional LLM → Heuristics fallback (OpenAI-compatible incl. Ollama /
Anthropic) with exact-match validation.
- M3 (not yet planned): HTML/JSX attribute values, CodeLens improvements, streamed progress
interleaved bracket kinds, candidate cycling.