feat: add C motion to change to end of line#77
Conversation
reobin
commented
Apr 27, 2026
- mirrors D: deletes from cursor to end of line and enters insert mode
- works with the existing register and undo flow
* mirrors D: deletes from cursor to end of line and enters insert mode * works with the existing register and undo flow
leohenon
left a comment
There was a problem hiding this comment.
Thanks, looks good. Just one visual-mode edge case: C now runs while already in visual mode and ignores the selection.
Repro:
- Type
one two three - Normal mode, cursor on
two - Press
v,w,C - Compare with
v,w,c
Expected: visual C should not fall through to normal-mode C.
Actual: it deletes from cursor to end of line, ignoring the visual selection.
A minimal fix would be to handle shifted C in the existing visual c branch:
if ((key === "c" || isShifted(event, "c")) && !hasModifier(event)) {
begin(() => {
const reg = deleteSelection(input.textarea(), lw, a ?? undefined)
if (reg) setRegister(reg)
clearSelection(input.textarea())
input.state.setMode("insert")
})
event.preventDefault()
return true
}Note: For closer Vim accuracy, visual C should be a linewise change. But visual D currently behaves like visual d, not linewise delete, so I don’t think we need to solve that yet, just the minimal consistency fix is enough here.
A future change could make both visual D and visual C linewise but I dont think thats necessary for now.
|
@leohenon I ended up making it vim-accurate for |