1. Start diff
There are many ways to turn on diff in Vim, and here are a few common scenarios.
1.1 External directly open two files
# Direct use of Vimdiff instructions
Vimdiff file_1 file_2
-D file_1 file_2
1.2 File comparison after opening a file
-on File_1 file_2:diffthis # to enter in two windows
2. Change the file location
You can change the display location of the comparison file according to your personal habits and file format.
Ctrl-w K # Move the current window to the top ctrl-w H # Move the current window to the leftmost ctrl-w J # Move the current window to the bottom ctrl-w L # Move the current window to the far right
3. Locking and unlocking
When comparing files, the default is to lock the scroll bar of two files.
: Set Noscrollbind # Unlocked: Set Scrollbind # Locked (will be re-aligned)
4. Move the cursor
You need to move the cursor position when you modify the file, you can move it under vim, but there is a shortcut key that jumps to the difference row.
Use of diff in vim