Skip to content

feat: add C motion to change to end of line#77

Merged
leohenon merged 4 commits intoleohenon:ocvfrom
reobin:feat/big-c-motion
Apr 27, 2026
Merged

feat: add C motion to change to end of line#77
leohenon merged 4 commits intoleohenon:ocvfrom
reobin:feat/big-c-motion

Conversation

@reobin
Copy link
Copy Markdown

@reobin 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
Copy link
Copy Markdown
Owner

@leohenon leohenon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, looks good. Just one visual-mode edge case: C now runs while already in visual mode and ignores the selection.

Repro:

  1. Type one two three
  2. Normal mode, cursor on two
  3. Press v, w, C
  4. 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.

@reobin
Copy link
Copy Markdown
Author

reobin commented Apr 27, 2026

@leohenon I ended up making it vim-accurate for C and D. it will do linewise now.

@leohenon leohenon merged commit a024ba5 into leohenon:ocv Apr 27, 2026
1 check passed
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.

2 participants