All Projects β†’ rickhowe β†’ Diffchar.vim

rickhowe / Diffchar.vim

Highlight the exact differences, based on characters and words

Projects that are alternatives of or similar to Diffchar.vim

spotdiff.vim
A range and area selectable diffthis to compare partially
Stars: ✭ 29 (-78.03%)
Mutual labels:  diff, vim-plugin
Vim Mergetool
🍰 Efficient way of using Vim as a Git mergetool
Stars: ✭ 179 (+35.61%)
Mutual labels:  vim-plugin, diff
Incsearch Fuzzy.vim
Stars: ✭ 116 (-12.12%)
Mutual labels:  vim-plugin
Quickfixsigns vim
Mark quickfix & location list items with signs
Stars: ✭ 126 (-4.55%)
Mutual labels:  vim-plugin
Vim Operator Surround
Vim operator mapping to enclose text objects with surrounds like paren, quote and so on.
Stars: ✭ 124 (-6.06%)
Mutual labels:  vim-plugin
Csv Diff
Python CLI tool and library for diffing CSV and JSON files
Stars: ✭ 118 (-10.61%)
Mutual labels:  diff
Learnvue
Vue.js 源码解析
Stars: ✭ 11,516 (+8624.24%)
Mutual labels:  diff
Sqhell.vim
An SQL wrapper for vim
Stars: ✭ 113 (-14.39%)
Mutual labels:  vim-plugin
Diff2html
Pretty diff to html javascript library (diff2html)
Stars: ✭ 1,867 (+1314.39%)
Mutual labels:  diff
Daff
Diff, patch and merge for data.frames, see http://paulfitz.github.io/daff/
Stars: ✭ 121 (-8.33%)
Mutual labels:  diff
Winmerge
WinMerge is an Open Source differencing and merging tool for Windows. WinMerge can compare both folders and files, presenting differences in a visual text format that is easy to understand and handle.
Stars: ✭ 2,358 (+1686.36%)
Mutual labels:  diff
Phoenix Diff
See the changes needed when upgrading an Elixir Phoenix application
Stars: ✭ 120 (-9.09%)
Mutual labels:  diff
Shinny Futures Android
δΈ€δΈͺεΌ€ζΊηš„ android εΉ³ε°ζœŸθ΄§θ‘Œζƒ…δΊ€ζ˜“η»ˆη«―
Stars: ✭ 120 (-9.09%)
Mutual labels:  diff
Php Diff
A comprehensive library for generating differences between two strings in multiple formats (unified, side by side HTML etc).
Stars: ✭ 126 (-4.55%)
Mutual labels:  diff
Vim Youdao Translater
vimηš„ζœ‰ι“ε–θ―ηΏ»θ―‘ζ’δ»Ά
Stars: ✭ 116 (-12.12%)
Mutual labels:  vim-plugin
Vim Clap
πŸ‘ Modern performant fuzzy picker for Vim and NeoVim
Stars: ✭ 1,802 (+1265.15%)
Mutual labels:  vim-plugin
Nvim Treesitter Context
Show code context
Stars: ✭ 113 (-14.39%)
Mutual labels:  vim-plugin
Vim Gdscript3
Syntax highlighting and completion for GDScript 3
Stars: ✭ 121 (-8.33%)
Mutual labels:  vim-plugin
Prettydiff
Beautifier and language aware code comparison tool for many languages. It also minifies and a few other things.
Stars: ✭ 1,635 (+1138.64%)
Mutual labels:  diff
Golive
⚑ Live views for GoLang with reactive HTML over WebSockets πŸ”Œ
Stars: ✭ 130 (-1.52%)
Mutual labels:  diff

diffchar.vim

Highlight the exact differences, based on characters and words

 ____   _  ____  ____  _____  _   _  _____  ____   
|    | | ||    ||    ||     || | | ||  _  ||  _ |  
|  _  || ||  __||  __||     || | | || | | || | ||  
| | | || || |__ | |__ |   __|| |_| || |_| || |_||_ 
| |_| || ||  __||  __||  |   |     ||     ||  __  |
|     || || |   | |   |  |__ |  _  ||  _  || |  | |
|____| |_||_|   |_|   |_____||_| |_||_| |_||_|  |_|

Introduction

This plugin has been developed in order to make diff mode more useful. Vim highlights all the text in between the first and last different characters on a changed line. But this plugin will find the exact differences between them, character by character - so called DiffChar.

For example, in diff mode:
example1

This plugin will exactly show the changed and added units:
example2

This plugin will synchronously show/reset the highlights of the exact differences as soon as the diff mode begins/ends. And the exact differences will be kept updated while editing.

This plugin shows the differences based on a g:DiffUnit. Its default is 'Word1' and it handles a \w\+ word and a \W character as a difference unit. There are other types of word provided and you can also set 'Char' to compare character by character.

In diff mode, the corresponding hl-DiffChange lines are compared between two windows. You can set a number of matching colors to a g:DiffColors to make it easy to find the corresponding units between two windows. As a default, all the changed units are highlighted with hl-DiffText. In addition, hl-DiffAdd is always used for the added units and both the previous and next character of the deleted units are shown in bold/underline.

While showing the exact differences, when the cursor is moved on a difference unit, you can see its corresponding unit highlighted with hl-Cursor, hl-TermCursor, or similar one in another window, based on a g:DiffPairVisible. If you change its default, the corresponding unit is echoed in the command line or displayed in a popup/floating window just below the cursor position or at the mouse position.

You can use ]b or ]e to jump cursor to start or end position of the next difference unit, and [b or [e to the start or end position of the previous unit. Those keymaps are configurable in your vimrc and so on.

Like line-based :diffget/:diffput and do/dp vim commands, you can use <Leader>g and <Leader>p commands in normal mode to get and put each difference unit, where the cursor is on, between 2 buffers and undo its difference.

When the diff mode begins, this plugin locally checks the hl-DiffChange lines in the limited range of the current visible and its upper/lower lines of a window. And each time a cursor is moved on to a different range upon scrolling or searching, the new hl-DiffChange lines will be incrementally checked in that range. Which means, independently of the file size, the number of lines to be checked and then the time consumed are always constant.

This plugin works on each tab page individually. You can use a tab page variable (t:), instead of a global one (g:), to specify different options on each tab page. Note that this plugin can not handle more than two diff mode windows in a tab page. If it would happen, to prevent any trouble, all the highlighted units are to be reset in the tab page.

To find the exact differences, this plugin uses "An O(NP) Sequence Comparison Algorithm" developed by S.Wu, et al., which always finds an optimum sequence. But it takes time to check a long and dissimilar line. To improve the performance, if there are so many diff units included in a line or it has taken much time in a diff session, this plugin tries to use the external diff command together if available.

Options

  • g:DiffUnit, t:DiffUnit: A type of difference unit

    • 'Char' : any single character
    • 'Word1' : \w\+ word and any \W single character (default)
    • 'Word2' : non-space and space words
    • 'Word3' : \< or \> character class boundaries
    • 'CSV(,)' : separated by characters such as ',', ';', and '\t'
  • g:DiffColors, t:DiffColors: Matching colors for changed units

    • 0 : hl-DiffText (default)
    • 1 : hl-DiffText + up to 3 other highlights
    • 2 : hl-DiffText + up to 7 other highlights
    • 3 : hl-DiffText + up to 15 other highlights
  • g:DiffPairVisible, t:DiffPairVisible: Visibility of corresponding diff units

    • 0 : disable
    • 1 : highlight with hl-Cursor (default)
    • 2 : highlight with hl-Cursor + echo in the command line
    • 3 : highlight with hl-Cursor + popup/floating window at cursor position
    • 4 : highlight with hl-Cursor + popup/floating window at mouse position

Keymaps

  • <Plug>JumpDiffCharPrevStart (default: [b)
    • Jump cursor to the start position of the previous difference unit
  • <Plug>JumpDiffCharNextStart (default: ]b)
    • Jump cursor to the start position of the next difference unit
  • <Plug>JumpDiffCharPrevEnd (default: [e)
    • Jump cursor to the end position of the previous difference unit
  • <Plug>JumpDiffCharNextEnd (default: ]e)
    • Jump cursor to the end position of the next difference unit
  • <Plug>GetDiffCharPair (default: <Leader>g)
    • Get a corresponding difference unit from another buffer to undo difference
  • <Plug>PutDiffCharPair (default: <Leader>p)
    • Put a corresponding difference unit to another buffer to undo difference

Demo

demo

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].