|
| 1 | +# VSCodeVim — Agent Instructions |
| 2 | + |
| 3 | +VSCodeVim is a VS Code extension (TypeScript) that emulates Vim modal editing. It targets both desktop and web VS Code environments. |
| 4 | + |
| 5 | +## Build & Test |
| 6 | + |
| 7 | +```bash |
| 8 | +yarn build-dev # Fast dev build |
| 9 | +yarn build # Production build |
| 10 | +yarn watch # Rebuild on file changes |
| 11 | + |
| 12 | +yarn build-test && yarn test # Run tests locally (close all VS Code instances first) |
| 13 | +npx gulp test # Run tests in Docker (preferred) |
| 14 | +npx gulp test --grep <REGEX> # Run filtered tests in Docker |
| 15 | + |
| 16 | +yarn lint # Check code style |
| 17 | +yarn lint:fix # Auto-fix linting issues |
| 18 | +yarn prettier # Format code |
| 19 | +``` |
| 20 | + |
| 21 | +## Architecture |
| 22 | + |
| 23 | +**Event flow:** Key press → `extension.ts` → `ModeHandler.handleKeyEvent()` → action matching → `runAction()` → `updateView()` |
| 24 | + |
| 25 | +Key directories: |
| 26 | + |
| 27 | +- `src/actions/` — All command/motion/operator implementations; large consolidated files (e.g. `insert.ts`, `search.ts`) are intentional |
| 28 | +- `src/actions/plugins/` — Emulated Vim plugins (easymotion, surround, sneak, commentary, etc.) |
| 29 | +- `src/mode/modeHandler.ts` — Central state machine; one instance per open editor |
| 30 | +- `src/state/vimState.ts` — Per-editor state (cursor, registers, mode, history) |
| 31 | +- `src/state/recordedState.ts` — Transient state for the current operation; resets after each action |
| 32 | +- `src/cmd_line/` — Ex command (`:`) parsing and execution |
| 33 | +- `src/configuration/` — Settings loading and validation |
| 34 | +- `src/neovim/` — Optional Neovim process integration for Ex commands |
| 35 | +- `src/platform/node/` and `src/platform/browser/` — Platform-specific abstractions |
| 36 | +- `test/` — Mirrors `src/` structure; uses Mocha + Sinon + `@vscode/test-electron` |
| 37 | + |
| 38 | +**Three action base classes:** |
| 39 | + |
| 40 | +- `BaseMovement` — Updates cursor only; returns `Position` or `IMovement` (start+end for text objects) |
| 41 | +- `BaseCommand` — Modifies `VimState` beyond cursor movement |
| 42 | +- `BaseOperator` — Combines with a movement (e.g. `d{motion}`, `c{motion}`) |
| 43 | + |
| 44 | +## Conventions |
| 45 | + |
| 46 | +- TypeScript `strict: true` + `noImplicitOverride: true` — always use the `override` keyword when overriding parent methods |
| 47 | +- `IMovement` interface (not just `Position`) is required when a motion needs to return a range (e.g. text objects like `aw`, `i{`) |
| 48 | +- Platform abstraction via `/src/platform/` — never call Node.js APIs directly; use the abstraction layer so web VS Code works |
| 49 | +- Settings precedence: Ex-commands → user/workspace VS Code settings → defaults |
| 50 | +- `.vimrc` support is remaps-only — no full Vimscript execution |
| 51 | +- Actions are registered by decorating classes; see existing action files for the pattern |
| 52 | + |
| 53 | +## References |
| 54 | + |
| 55 | +- [CONTRIBUTING.md](.github/CONTRIBUTING.md) — Setup, architecture deep-dive, release process |
| 56 | +- [README.md](README.md) — All supported settings, emulated plugins, keybindings |
| 57 | +- `gulpfile.js` — Build/test/release automation tasks |
| 58 | +- `package.json` — Extension manifest, all configuration schema definitions (40+ settings) |
0 commit comments