PCode Merge is a fast, keyboard-centric, vim-inspired patch merging and conflict resolution tool built with Rust and egui. It is designed to streamline the workflow of applying patches, reviewing diffs, and managing local file edits—especially in AI-assisted coding workflows where patches are generated by LLMs (like Aider) or standard git diff/unified diff formats.
rustconcat_patch_merge.mp4
- Multi-Format Patch Parsing: Automatically detects and parses Aider-style search/replace blocks, standard Git/Unified diffs, and raw pastes.
- Vim-like Modal Editing: Navigate and edit files seamlessly using familiar Vim-style keybindings (Normal, Insert, Visual modes).
- Smart Auto-Matching: Utilizes LCS-based diffing to automatically find the best location in your file to apply a patch.
- Manual Anchors (
ma,mA): Force-apply patches to specific lines or ranges using manual anchors when auto-matching fails. - Git Integration: View line-by-line Git status, grouped Git hunks, and overall repo status directly in the UI.
- Repository Management: Register and sync multiple local repositories via a background daemon.
- Format on Save: Automatically format files using
rustfmtor custom formatting commands upon saving.
- Rust and Cargo installed.
git2system libraries (usually requireslibgit2andlibssl-devon Linux).
cargo build --releaseYou can run the tool directly, optionally passing a patch file:
# Start with an empty workspace
cargo run --release
# Start by loading a specific patch file
cargo run --release -- path/to/your/patch.mdPCode Merge is designed to keep your hands on the keyboard. Here are the core bindings:
| Key | Action |
|---|---|
L / Shift+L |
Next / Previous hunk |
Alt + = / Alt + - |
Next / Previous file (if multiple in patch) |
F1 / F4 / F3 |
Toggle Git Status / Git Diff / Debug panels |
? |
Toggle Help overlay |
Alt + W |
Save current file to disk |
Alt + Q |
Quit application |
Esc |
Cancel current action / Clear marks / Exit insert mode |
| Key | Action |
|---|---|
Arrow Keys / hjkl |
Move cursor |
Space |
Set mark a (ma) at cursor line |
m + [letter] |
Set a custom marker |
A |
Apply current hunk at auto-matched location |
+ / - |
Shrink/Expand the auto-match range or anchor a range |
/ |
Search forward in file |
n / N |
Next / Previous search match |
v |
Toggle Visual mode for block selection |
| Key | Action |
|---|---|
i / I |
Enter Insert mode (at cursor / start of line / append) |
o / O |
Open new line below/above and enter Insert mode |
dd |
Delete current line |
daf |
Delete function block around cursor |
u |
Undo last edit |
yy |
Yank (copy) current line |
p / P |
Paste yanked line below / above |
Esc |
Return to Normal mode |
- Load a Patch: Click
📋 Paste Patchto load from clipboard, or📝 Paste Manuallyto paste text directly. You can also launch the app with a file path argument. - Set Target File: If the patch doesn't specify a filename, enter the target file path in the
Target Fileinput box on the left panel. - Review the Hunk: Use
L/Shift+Lto navigate between hunks. The right panel will highlight the best auto-match location in the file. - Apply the Hunk:
- Press
Ato apply at the auto-matched location. - If the auto-match is wrong, move your cursor to the correct starting line, press
Space(to setma), then pressA. - To apply a custom range, set
maat the start, move to the end line, pressmA(or use the+/-keys to expand the range), then apply.
- Press
- Save: Press
Alt + Wto write the changes to disk. IfFormat on Saveis enabled, it will run your formatter automatically.
Settings are automatically saved and loaded from a config file. You can modify these via the ⚙ Config tab in the UI:
- Format on Save: Toggle automatic formatting.
- Format Command: The command to run for formatting (e.g.,
rustfmt,rustfmt --edition 2021,cargo fmt --).