Linux command
vimdiff 命令
文件
复制后可按需替换文件名、目录或参数。
常用示例
Compare two files
vimdiff [file1] [file2]
Compare three files
vimdiff [file1] [file2] [file3]
Open files in read-only mode
vimdiff -R [file1] [file2]
Use horizontal split
vimdiff -o [file1] [file2]
Start with a clean environment
vimdiff --clean [file1] [file2]
Compare files with a specific command
vimdiff -c "[command]" [file1] [file2]
说明
vimdiff starts Vim in diff mode with two to eight files, each in its own window. Differences between files are highlighted, making it easy to compare and merge changes. This is equivalent to running vim -d file1 file2. In diff mode, Vim automatically sets options for synchronized scrolling (scrollbind), difference highlighting, and folding of unchanged lines. Within vimdiff, use ]c and [c to jump between differences. Use do (diff obtain) to pull changes from another window, and dp (diff put) to push changes to another window. Use :diffupdate to refresh highlighting after edits.
参数
- -O
- Open windows vertically, side by side (default for two files).
- -o
- Open windows horizontally, stacked.
- -R
- Open all files in read-only mode.
- -c _command_
- Execute command after loading the first file.
- --clean
- Start without loading .vimrc or plugins.
- -d
- Explicitly enable diff mode (automatic with vimdiff).
FAQ
What is the vimdiff command used for?
vimdiff starts Vim in diff mode with two to eight files, each in its own window. Differences between files are highlighted, making it easy to compare and merge changes. This is equivalent to running vim -d file1 file2. In diff mode, Vim automatically sets options for synchronized scrolling (scrollbind), difference highlighting, and folding of unchanged lines. Within vimdiff, use ]c and [c to jump between differences. Use do (diff obtain) to pull changes from another window, and dp (diff put) to push changes to another window. Use :diffupdate to refresh highlighting after edits.
How do I run a basic vimdiff example?
Run `vimdiff [file1] [file2]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does -O do in vimdiff?
Open windows vertically, side by side (default for two files).