Skip to content

feat(editor): support newlines in substitute replacements - #320

Merged
fcoury-oai merged 1 commit into
mainfrom
fcoury/substitute-newline
Aug 22, 2026
Merged

fcoury-oai merged 1 commit into
mainfrom
fcoury/substitute-newline

Conversation

@fcoury-oai

Copy link
Copy Markdown
Collaborator

Visual-range substitutions could only insert literal escape text, leaving no interactive way to split matches into new lines.

This adds Vim-style \r decoding for substitute replacement templates before Rust capture expansion. Inserted line breaks preserve the target line LF or CRLF ending, while \\ inserts a literal backslash. The compatibility matrix documents the remaining Rust-regex differences, including $0/$1/$name captures and literal \n behavior.

Focused integration coverage exercises the Visual-line command path, undo, CRLF preservation, and non-newline escapes.

How to Test

  1. Select two lines containing spaces in Visual-line mode, press :, and run s/ /\r/g.
    Expected: every selected space becomes a line break, and one undo restores the original selected lines.
  2. Run cargo test --test editing substitute_.
    Expected: all 11 substitution tests pass, including visual_substitute_replacement_supports_vim_line_breaks, substitute_line_break_replacement_preserves_crlf, and substitute_replacement_preserves_non_newline_escapes.

@fcoury-oai
fcoury-oai merged commit 2cf819e into main Aug 22, 2026
10 checks passed
@fcoury-oai
fcoury-oai deleted the fcoury/substitute-newline branch August 22, 2026 22:45
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