Thanks to visit codestin.com
Credit goes to github.com

Skip to content

allenk/vscode-partial-diff

 
 

Repository files navigation

Build Status Code Climate

Partial Diff

Features

  • 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)

Compare two text selections

Commands

  • 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 Compare or Compare Text with Previous Selection command without selecting any text will use the entire text of the current file.

Configurations

  • 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, replaceWith and optionally name.

    • 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, where N is the index of substring (starting from 1) you captured in match with ().
      • Letter case specification as an object. Valid cases are upper and lower.

    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"}
      }
      ...
    ]
    

Keyboard Shortcuts

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" },

Known problems

Request Features or Report Bugs

Changelog

How to Contribute

  1. Clone this repository

  2. Make code changes

  3. Before you make a pull request, you can run linter and tests to avoid build failure

    $ npm run prep

About

Visual Studio Code Extension. Take a diff of 2 parts of text(s)

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages

  • JavaScript 100.0%