Skip to content

feat(commands): add bufdo support - #311

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

fcoury-oai merged 1 commit into
mainfrom
fcoury/bufdo

Conversation

@fcoury-oai

Copy link
Copy Markdown
Collaborator

Red can navigate and edit multiple open buffers, but it lacks Vim's :bufdo workflow for applying one Ex command across them. That makes project-wide buffer edits repetitive and prevents familiar stop-on-error behavior.

This adds :[buffer-id-range]bufd[o][!] {command} with a stable snapshot of open buffer IDs. The command visits matching buffers in ID order, reparses the nested command for each buffer, stops on the first error, and leaves the last or failing buffer active. Nested completion works for command names and arguments, and substitute commands accept e to continue past missing matches.

Traversal is intentionally limited to non-interactive built-ins that do not restructure buffers or windows. Modal UI, plugin commands, recursive :bufdo, and | command chains are rejected before execution.

How to Test

  1. Run CARGO_TARGET_DIR=/private/tmp/red-bufdo-target cargo test --test editing bufdo. The three focused tests should pass, covering full traversal, stable-ID ranges, stop-on-error behavior, the substitute e flag, and unsupported nested commands.
  2. Open several buffers containing foo, run :bufdo %s/foo/bar/g, and confirm every buffer is updated and the final buffer remains active.
  3. Repeat with one buffer that has no match. Without e, traversal should stop on that buffer and leave later buffers unchanged; with :bufdo %s/foo/bar/ge, traversal should continue through the final buffer.

@fcoury-oai
fcoury-oai merged commit 5d1d34a into main Aug 22, 2026
10 checks passed
@fcoury-oai
fcoury-oai deleted the fcoury/bufdo branch August 22, 2026 20:20
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