feat: word text objects (iw/aw) - #68
Merged
Merged
Conversation
diw/ciw/yiw/daw/caw/yaw and viw/vaw, routed through a new resolveTextObject seam (src/vim/textobject.ts) so quote/bracket objects can be added later without touching the handlers. - fix #57: after an operator, i/a now start a text object instead of falling through to insert mode - wordRange treats CR as a line boundary (CRLF-safe) - extract applyOperatorRange to share the operator+e / operator+G / text-object apply-to-range logic
oribarilan
added a commit
that referenced
this pull request
Sep 2, 2026
Adds quote and bracket text objects on top of the `resolveTextObject` seam from #68. ## Objects - Quotes: `i"` `i'` `` i` `` (with `a` variants) - Brackets: `i(` `i{` `i[` `i<` (with `a` variants), from either delimiter - `iq` for the nearest quote of any type (`"` `'` `` ` ``) - `ib` for the nearest bracket of any type (`()` `{}` `[]`) Works with `d`/`c`/`y` and in visual mode: `di"`, `ci(`, `da{`, `dib`, `ciq`, `vi[`, and so on. ## Design Purely additive over the seam: only `text.ts` (new pure functions `bracketRange`, `quoteRange`, `anyQuoteRange`, `anyBracketRange`) and `textobject.ts` (new `case` arms) changed. `normal.ts` and `visual.ts` are untouched. ## Notes - `ib` means any bracket, not vim's parens-only `ib` (documented in the README). Use `i(` for parentheses specifically. - Empty pairs no-op: `di"` on `""` and `ci(` on `()` do nothing (the action model has no zero-width insert yet). ## Testing `just check` green: 309 tests, lint clean. Covers nesting, multiline brackets, cursor-on-delimiter, empty pairs, line-scoped quotes, tightest-enclosing `iq`/`ib`, and a `db`-stays-a-motion regression guard.
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds vim word text objects
iw/awfor thed/c/yoperators and visual mode:diw ciw yiw daw caw yaw viw vaw.Design
All object chars route through one seam,
resolveTextObjectinsrc/vim/textobject.ts, so the follow-up (quote/bracket pairs, plusiq/ib) adds onlycasearms + apairRangeintext.ts— no handler changes. The pure range algorithm (wordRange) lives intext.ts; the handlers gained ~2 small blocks each.Included
i/astart a text object instead of falling through to insert.wordRangetreats CR as a line boundary (CRLF-safe).applyOperatorRangeto dedupe the operator+e / operator+G / text-object apply-to-range logic.Testing
just checkgreen: 260 tests, lint clean. New unit tests forwordRange,resolveTextObject, and the normal/visual handler branches (including the #57 regression).Deferred (deliberate)
d2iw) acts asdiw.vi<Esc>cancels the pending object but stays in visual (avoids a pending-state leak into normal).Closes #57.