clipboard-diff-patch is a Visual Studio Code extension that allows you to apply diff patches directly from your clipboard to the currently open file. This can be particularly useful for developers who frequently work with patches and need a quick way to apply them without leaving the editor.
- Apply Diff Patch from Clipboard: Apply a diff patch from the clipboard to the active file in the editor.
- Error Handling: Provides informative messages if the clipboard content is not a valid diff patch or if no active editor is found.
- Copy a diff patch to your clipboard.
- Open the file you want to apply the patch to in Visual Studio Code.
- Open the Command Palette by pressing
Ctrl+Shift+P. - Type
Apply Diff Patch from Clipboardand select the command.
-
Create a Diff Patch: Suppose you have the following original file
example.txt:Line 1 Line 2 Line 3
And you want to change
Line 2toLine 2 modified. You create a diff patch:--- esc5221.txt +++ esc5221.txt @@ -1,3 +1,3 @@ Line 1 -Paste each hunk +Use Clipboard Diff Patch Line 3
-
Copy the Diff Patch: Copy the above diff patch to your clipboard.
-
Open the File in VSCode: Open
example.txtin Visual Studio Code. -
Apply the Patch:
- Open the Command Palette by pressing
Ctrl+Shift+P. - Type
Apply Diff Patch from Clipboardand select the command.
- Open the Command Palette by pressing
-
Result: The content of
example.txtwill be updated to:Line 1 Line 2 modified Line 3
- Visual Studio Code version 1.86.0 or higher.
This extension does not contribute any settings.
- The extension may fail to apply patches if the context lines in the patch do not match the content of the file exactly.
- Only supports unified diff format.
- Initial release of
clipboard-diff-patch.
If you encounter any issues or have feature requests, please feel free to open an issue or submit a pull request on the GitHub repository.
This project is licensed under the MIT License - see the LICENSE file for details.
