Skip to content

feat(editor): add vim-style multi-cursor editing - #326

Merged
fcoury-oai merged 8 commits into
mainfrom
fcoury/multi-cursor-ctrl-n
Aug 23, 2026
Merged

fcoury-oai merged 8 commits into
mainfrom
fcoury/multi-cursor-ctrl-n

Conversation

@fcoury-oai

Copy link
Copy Markdown
Collaborator

Red currently requires repeated edits or blockwise workarounds when the same text needs to change in several places. This adds a Vim-style multi-cursor workflow for selecting repeated occurrences or aligned positions and editing them as one operation.

What Changed

  • Add Ctrl-n occurrence selection with forward/backward navigation, wrapping, skipping, removal, smart-case matching, and stable buffer/window ownership.
  • Apply insert, append, change, delete, yank, and paste across all selected regions as one undoable edit while preserving ordered per-region register payloads.
  • Add Ctrl-Up and Ctrl-Down vertical cursors with display-column alignment, shorter-line skipping, empty-line handling at column zero, and tab-aware positioning.
  • Add extend mode with Tab, Shift-arrow selection, h/l/w/e/0/$ motions, anchor inversion with o, and Ctrl-n word promotion for vertical cursors.
  • Render active multi-cursor regions and expose their position in the status line without replacing normal search state.

How to Test

  1. Open a buffer containing foo one foo two foo. Place the cursor on the first foo, press Ctrl-n twice, then type cbar<Esc>. The first two occurrences should become bar; one u should restore both edits.
  2. Put the cursor at the same display column on several lines, including a shorter line and lines that mix tabs with spaces. Press Ctrl-Down repeatedly. Cursors should stay aligned by display column and skip lines that cannot reach it; at column zero, empty lines should receive a cursor.
  3. With vertical cursors active, press Shift-Right or Tab followed by e, then cX<Esc>. Every selected range should be replaced. Pressing o before another motion should extend from the opposite endpoint.
  4. Select repeated regions, yank with y, and paste with p or P. Each cursor should receive its corresponding payload in document order. Changing the system clipboard should replace the structured payload rather than replay stale regions.

Focused automated coverage:

  • cargo test --test multi_cursor
  • cargo test editing::multi_selection::tests --lib
  • cargo clippy --all-targets --all-features -- -D warnings

@fcoury-oai
fcoury-oai merged commit 94f71e7 into main Aug 23, 2026
8 of 11 checks passed
@fcoury-oai
fcoury-oai deleted the fcoury/multi-cursor-ctrl-n branch August 23, 2026 14:55
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.

1 participant