Vimdiff: Using the powerful file diff feature in vim [go]

Source: Internet
Author: User
Tags diff file diff

After studying vim for some time, it was not until recently that Vim's diff function was so convenient that it was no longer necessary to look for diff software or to rely on version-controlled diff in contrast to code changes. Powerful vim.

Is my diff effect in the Macvim.

The following is a common use of Vimdiff, summed up, not carefully read the manual, in a variety of scenarios is not necessarily able to immediately think of the most appropriate command.

To open vim directly in the terminal in diff mode:

1 vimdiff file1 file2 [File3 [file4]] #或者 2 vim-d file1 file2 [File3 [File4]]

Using the GUI (gVim):

1 gvimdiff file1 file2 [File3 [file4]] 2  3 #或者 4  5 vim-d-G file1 file2 [File3 [File4]]

Mac users use Macvim words as follows, which is not mentioned in Vim doc:

1 mvim-d-G file1 file2 [File3 [File4]]

The above operation will be vertical split to open the file for diff, if you want to use horizontal split, you can add the parameter-O

1 vimdiff-o file1 file22  3#或者如下, Gvim and Macvim analogy 4   5 vim-d-o file1 file2

The previous method is to use the diff mode to open vim directly, if you are already in Vim to enable diff mode, use the following command:

1 :d iffs[plit] {filename} #在当前窗口分割, load another file filename for diff 2  3 :d Ifft[his] #将当前文件加入diff 4  5 :d Iffp[atch] {patchfile} #将buffer中的文件载入当前窗口进行diff

All of the above actions can be added to Vimdiff's other-options.

If you want to use portrait splitting when loading a file, you can add the vert prefix command:

1 : vert diffs File2.txt

After the file changes, to refresh the diff, you can use the Diffupdate command

1 :d Iffu[pdate] #更新diff 2  3 :d iffu[pdate]! #对所有文件更新diff

Jump in diff:

1 ] C #下一个不同 2 [C #上一个不同

In diff mode, to turn off diff mode to return to normal mode, you can use the Diffoff command:

1 :d Iffo[ff] #将目前文件退出diff模式 2  3 :d iffo[ff]! #将目前窗口中的所有文件退出diff模式

These are commonly used vimdiff commands and methods, there are many complex commands without research and enumeration, such as diffexpr, diffcopying and so on, the function is more powerful.

It's so easy to switch, diff, and jump to see changes in the version file, in Vim!

Vimdiff: Using the powerful file diff feature in vim [go]

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.