Skip to content

fix(evil): make cc/S respect visual-line-mode#8672

Open
kovan wants to merge 1 commit into
doomemacs:masterfrom
kovan:fix/evil-visual-line-cc
Open

fix(evil): make cc/S respect visual-line-mode#8672
kovan wants to merge 1 commit into
doomemacs:masterfrom
kovan:fix/evil-visual-line-cc

Conversation

@kovan

@kovan kovan commented Feb 13, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Add +evil:change-whole-visual-line operator that correctly handles visual lines when evil-respect-visual-line-mode is enabled
  • Remap cc and S to the new operator in visual-line-mode normal state
  • Fixes the long-standing issue where cc on a wrapped visual line deletes the newline, collapsing the next physical line

Context

When evil-respect-visual-line-mode is t, cc (evil-change-whole-line) deletes the entire physical line including its newline, because evil-change-whole-line has :type line which re-expands visual line boundaries to physical lines. This makes the setting unusable — it's been toggled on/off multiple times and currently defaults to nil.

The new operator detects whether the visual line spans a full physical line:

  • Full physical line(s): delegates to evil-change with 'line type (preserving normal cc behavior with auto-indent)
  • Visual line subset of a wrapped line: uses 'inclusive type to delete only the visual line content without eating the newline
  • Empty line: falls through to evil-insert

Related upstream evil issues: emacs-evil/evil#188, emacs-evil/evil#1168

Fix: #2447

Test plan

  • Set evil-respect-visual-line-mode to t
  • Open a file with a long wrapped line — cc on a visual line should clear only that visual line, not the entire physical line
  • On a non-wrapped line — cc should work normally (clear line, enter insert with indentation)
  • On an empty line — cc should enter insert mode
  • Count prefix (3cc) should change 3 visual lines
  • Register support ("acc) should yank deleted text into register a
  • S should behave identically to cc

  • I searched the issue tracker and this hasn't been PRed before.
  • My changes are not on the do-not-PR list for this project.
  • My commits conform to Doom's git conventions.
  • I am blindly checking these off.
  • This PR contains AI-generated work.
  • Any relevant issues or PRs have been linked to.
  • This a draft PR; I need more time to finish it.

🤖 Generated with Claude Code

Add `+evil:change-whole-visual-line` operator that correctly handles
visual lines when `evil-respect-visual-line-mode` is enabled. The
built-in `evil-change-whole-line` always operates on physical lines
(including newlines), making `cc` delete the newline on wrapped lines.
The new operator detects whether the visual line spans a full physical
line and delegates accordingly.

Fix: doomemacs#2447

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

prevent evil-change-whole-line from deleting the line + newline

1 participant