- You can compare (diff) text selections within a file, across different files, or to the clipboard.
- Multi cursor text selection
- User defined text normalisation rules to reduce the noise in the diff (e.g. replace tab characters to spaces)
Select Text for Compare: Marks the selected text as the text to compare the next selection with.Compare Text with Previous Selection: Compares the selected text to the first selection.Compare Text with Clipboard: Compares the current clipboard to the selected text.
NOTE:
- A diff will be shown only after selecting comparison text first (using
Select Text for Compare). - Executing the
Select Text for CompareorCompare Text with Previous Selectioncommand without selecting any text will use the entire text of the current file.
-
partialDiff.preComparisonTextNormalizationRules: Rules to normalize texts for diff view.It doesn't mutate texts in the editors. Only texts in diff views get normalised. If a diff is presented with text normalised (or possibly normalised),
~is used in the diff title instead of↔)Each rule has
match,replaceWithand optionallyname.name: Optional. Name of the rule to describe what the rule is for.match: Regular expression to find text you want to normalise. Global search flag is automatically applied.replaceWith: One of the following- Replacement text as a string. You can use
$N, whereNis the index of substring (starting from 1) you captured inmatchwith(). - Letter case specification as an object. Valid cases are
upperandlower.
- Replacement text as a string. You can use
Sample
preComparisonTextNormalizationRules:"partialDiff.preComparisonTextNormalizationRules": [ { "name": "Replace tabs with whitespaces", "match": "\t", "replaceWith": " " }, { "name": "One space after comma", "match": ", *([^,\n]+)", "replaceWith": ", $1" }, { "name": "Capitalise", "match": ".*", "replaceWith": {"letterCase": "upper"} } ... ]
You can quickly mark the selected text by adding the partial-diff commands to your keyboard shortcut settings. For example:
{ "key": "ctrl+1", "command": "extension.partialDiff.markSection1",
"when": "editorTextFocus" },
{ "key": "ctrl+2", "command": "extension.partialDiff.markSection2AndTakeDiff",
"when": "editorTextFocus" },
{ "key": "ctrl+3", "command": "extension.partialDiff.diffSelectionWithClipboard",
"when": "editorTextFocus" },- If you want to compare text in Output channels, you'll need to execute the commands via keyboard shortcuts or the context menu (i.e. right-click menu). Executing the commands through the command palette doesn't work. See Cannot compare texts in Outputs channel if the mark text commands are executed from the command palette.
-
Clone this repository
-
Make code changes
-
Before you make a pull request, you can run linter and tests to avoid build failure
$ npm run prep
