Skip to content

e: multi-line pattern support for after/before/replace #2

@c3d4r

Description

@c3d4r

Problem

The e after, e before, and e replace commands only match single-line patterns. Real-world code patterns frequently span multiple lines:

// Can't match this with `e after`
type WindowSizeMsg struct {
    Width  int
    Height int
}

In our evaluation, both agents (Runs C and D) independently identified this as the main reason they preferred the built-in Edit tool over e for code modifications. When e after failed on a multi-line pattern, they had to fall back to e append with a line number, which is fragile (line numbers shift after edits).

Proposal

Support multi-line patterns in content-addressed commands:

# Match a multi-line block
e after file.go $'Height int\n}' 'new content'

# Or with --stdin for complex patterns
echo 'type WindowSizeMsg struct {
    Width  int
    Height int
}' | e --stdin replace file.go - 'replacement'

Design options

  1. Newline literals in patterns — interpret \n in pattern strings
  2. Multi-line stdin patterns — use --stdin to read the match pattern too (needs a separator or second flag)
  3. Heredoc-stylee after file.go <<'MATCH' <<'TEXT'

Option 1 is simplest and covers most cases. Option 2 handles arbitrary content.

Impact

Without this, e cannot compete with the built-in Edit tool for real-world code changes. The Edit tool's exact-string-match approach handles multi-line blocks naturally and was unanimously preferred by the evaluation agents.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions