Repository navigation
Fix w stepping over empty lines in vi mode - #135
Merged
Merged
Conversation
ernestrc
previously approved these changes
Sep 30, 2026
In Vim, w treats an empty line as a word, so it stops on it, and w on an empty line moves on to the next line. Rune skipped empty lines entirely and did nothing when the cursor was already on one. dw at the end of a line still stops before the empty line, and dw on an empty line deletes it. Signed-off-by: Vladimir Babin <[email protected]>
Counted dw/cw/yw from or across empty lines selected the wrong range, and cw on an empty line joined it with the next. Follow Vim: the last word ends at its line end, and an end in column 0 moves to the previous line, linewise from the indent. This also stops dfw/dtw from being treated as word motions, and pins the new standard-mode Ctrl+Delete behavior at empty lines introduced by the word motion change. Signed-off-by: ernestrc <[email protected]>
ernestrc
force-pushed
the
fix-w-empty-line
branch
from
September 30, 2026 14:24
e87b4f9 to
ccb3c02
Compare
ernestrc
approved these changes
Sep 30, 2026
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.
Fixes #132
In Vim,
wtreats an empty line as a word. Sowfrom the end of a line stops on the following empty line, andwon an empty line moves on to the next line. Rune'smoveAfterRuneskipped cells-less rows (cellAtCursorfails on them), sow/Wjumped over empty lines, and returned early when the cursor already sat on one.Changes:
moveAfterRunetakes astopAtEmptyLineflag.MoveRightStartWord/MoveRightStartWordGrouppasstrue; the backwardge/gEcallers passfalse, so their behaviour doesn't change. Whitespace-only lines are still skipped, as in Vim.handleMetaNormal: withwnow able to land on an empty line, the operator adjustment keepsdw/cwat the end of a line from eating the following empty line (one⏎⏎two,$dw→on⏎⏎two, matching the old behaviour and Vim).dwon an empty line deletes that line, as in Vim, where before it did nothing.Tests: added
TestViWordMotionEmptyLines(table-driven, 7 cases:$w,jw,$ww,$W, whitespace-only line,$dw,jdw).Validation:
go test ./internal/text/vi/ -run TestViWordMotionEmptyLines: 5/7 cases fail onmain, all pass with the fixgo test -race ./internal/text/...: all 12 packages passgofmt -l internal/: cleanNot run:
make lint(golangci-lint isn't installed on my machine) and the e2e suites.