|
External Merge for Visual Studio
|

A Visual Studio extension to launch your favorite external diff/merge tool to compare the active editor's content with your clipboard. Ideal for reviewing and integrating code snippets generated by AI assistants like Gemini, ChatGPT or Claude.
This project is a C#/.NET port of my original TypeScript extension for VS Code.
How It Works
When using an AI code assistant, you often get a large block of code. The standard workflow of copy-pasting overwrites your work and makes it difficult to see what changed.
This extension streamlines the process by letting you use a powerful, dedicated diff tool to see a side-by-side comparison, making it trivial to review, merge, and accept changes with confidence.

Features
- ✅ Launch Any Diff Tool: Configure the extension to use your favorite tool (Beyond Compare, KDiff3, WinMerge, Meld, etc.).
- 🚀 Side-by-Side View: Compares the content of your currently active editor tab with the text in your clipboard.
- 💾 Seamless Integration: After you merge and save in the external tool, the changes are instantly applied back to your editor in Visual Studio.
- ⌨️ Configurable Hotkey: Trigger the merge with a convenient keyboard shortcut (defaults to
Ctrl+Alt+M
).
- ⚡ Safe and Non-Blocking: The extension runs the external process asynchronously so Visual Studio remains responsive.
Installation
- Download the extension from the Visual Studio Marketplace.
- Double-click the downloaded
.vsix
file to install.
- Restart Visual Studio.
Configuration
All settings can be configured in Visual Studio via Tools > Options > External Merge.

The full, absolute path to your merge tool's executable.
- Example:
C:\Program Files\Beyond Compare 4\BCompare.exe
The command-line arguments to pass to the tool. The extension substitutes the following placeholders:
{filePath1}
: Path to a temporary file containing the active editor's content.
{filePath2}
: Path to a temporary file containing the clipboard content.
{outputFilePath}
: Path to the temporary file where the merged result should be saved.
Beyond Compare:
"{filePath1}" "{filePath2}" /savetarget="{outputFilePath}"
KDiff3:
"{filePath1}" "{filePath2}" -o "{outputFilePath}"
WinMerge:
(WinMerge modifies the second file in-place if no output is specified, but using the output argument is cleaner)
/e /u "{filePath1}" "{filePath2}" "{outputFilePath}"
(/e
closes WinMerge on a single Esc key press, /u
prevents adding paths to MRU list)
Meld:
(Meld typically modifies one of the input files. We can configure it to modify the "editor" temp file.)
"{filePath1}" "{filePath2}"
Rider merge:
diff "{filePath1}" "{filePath2}"
- Important: If your tool modifies an input file in-place (like Meld), make sure the
{outputFilePath}
placeholder is NOT present in your Tool Arguments
string. The extension will then correctly read the result from the {filePath1}
temp file.
Usage
- Open a file in the Visual Studio editor.
- Copy the new code you want to merge into your clipboard.
- In Visual Studio, press
Ctrl+Alt+M
(or trigger the command Tools > Merge with Clipboard
).
- Your external merge tool will launch with the two versions.
- Make your merges in the tool.
- Save the result and close the tool.
- The changes will be reflected in your Visual Studio editor.
Building from Source
If you want to build the extension yourself:
- Clone this repository.
- Make sure you have the Visual Studio extension development workload installed via the Visual Studio Installer.
- Open the
.sln
file in Visual Studio.
- Build the solution. The
.vsix
installer will be in the bin\Debug
or bin\Release
folder.
Contributing
Contributions are welcome! Please feel free to open an issue to report a bug or suggest a feature, or create a pull request with your improvements.
License
This project is licensed under the MIT License.