Home

Awesome

spotdiff.vim

A range and area selectable :diffthis to compare partially

Vim provides a diff mode which is useful to see differences between windows. However, it always shows the differences for entire line. And it can not compare a sequence of words within a line, and sentences and paragraphs which are separated into several lines.

To compare partially everywhere in any window, this plugin provides two groups of commands, which are alternative to vim original :diffthis, :diffoff, and :diffupdate. One is for which allows to select a range of lines in diff mode. Another is for which allows to select the Visual, motion, and text object area in non-diff normal mode. Both work independently in a tab page.

Selecting a range of lines

There are :Diffthis, :Diffoff, and :Diffupdate commands available.

You can use :Diffthis to specify a range of lines to be compared. And can use :Diffoff to reset and :Diffupdate to update the differences.

Do not use vim original diff commands together with this plugin's ones. Try :Diffoff! to reset all in a trouble.

If you have installed diffchar.vim plugin, you can see the exact differences and use their options and keymaps.

Commands

Demo

demoRS

Selecting the Visual, motion, and text object area

There are :VDiffthis, :VDiffoff, and :VDiffupdate commands available.

You can use :VDiffthis to specify the Visual area to be compared. And can use :VDiffoff to reset and :VDiffupdate to update the differences. Note that those commands work in non-diff normal mode.

While showing the exact differences, when the cursor is moved on a difference unit, you can see its corresponding unit highlighted in hl-Cursor, according to the g:DiffPairVisible option.

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.

This plugin provides the corresponding mappings to those commands, such as <Plug>(VDiffthis) and <Plug>(VDiffoff). As a default, <Leader>t and <Leader>o keys are mapped to them and, for example, v$<Leader>t selects the text from the current cursor position to the end of line and 3vis<Leader>t selects the next 3 sentences as the Visual area. And <Leader>o clears the selected area.

In addition to selecting the Visual area, you can use <Leader>t as a custom operator followed by a motion or a text object command, which will set those selected area as the Visual one and then call :VDiffthis. For example, <Leader>t$ and <Leader>t3is work same as above examples.

Commands

Options

These options are same as those used in the diffchar.vim plugin.

Keymaps

These keymaps are same as those used in the diffchar.vim plugin.

MappingDefault KeyDescription
<Plug>JumpDiffCharPrevStart[bJump cursor to the start position of the previous diff unit
<Plug>JumpDiffCharNextStart]bJump cursor to the start position of the next diff unit
<Plug>JumpDiffCharPrevEnd[eJump cursor to the end position of the previous diff unit
<Plug>JumpDiffCharNextEnd]eJump cursor to the end position of the next diff unit

These keymaps are used only in this plugin.

MappingDefault KeyDescription
<Plug>(VDiffthis)<Leader>t* Call :VDiffthis for the visually selected area<br>* Set the selected motion and text object area as the Visual one and then call :VDiffthis
<Plug>(VDiffthis!)<Leader>T* Call :VDiffthis! for the visually selected area<br>* Set the selected motion and text object area as the Visual one and then call :VDiffthis!
<Plug>(VDiffoff)<Leader>oCall :VDiffoff in the current window
<Plug>(VDiffoff!)<Leader>OCall :VDiffoff! in the current tab page
<Plug>(VDiffupdate)<Leader>uCall :VDiffupdate in the current tab page

Demo

demoVS