vimdiff常见操作

vimdiff是一个方便的文本类型的比较工具。命令如下:
$> vimdiff file1 file2

默认是窗口被切分成左右2个小窗口,不同之处会高亮显示,可以采用快捷键 ]c 调到下一个不同处,[c调到上一个不同处。

我通常采用这个工具比较代码和合并代码,可以配置git采用vimdiff比较合并代码
$> git config –global diff.tool vimdiff
$> git config –global merge.tool vimdiff

更过如何配置vimdiff为git的比较合并工具参看:
https://medium.com/usevim/git-and-vimdiff-a762d72ced86

合并代码时候需要把左边某一块代码放到右边,或者反过来,通常我们采用复制粘贴,但是vimdiff提供了do,dp的快捷键的。下面列出常用的快捷键

do - Get changes from other window into the current window.

dp - Put the changes from current window into the other window.

]c - Jump to the next change.

[c - Jump to the previous change.

zo - Open folded lines.

zc - Close folded lines.

zr - Unfold both files completely.

zm - Fold both files completely.

Ctrlww - change window.

:only | wq - quit other windows, write and quit.
    分享到:

留言

你的邮箱是保密的 必填的信息用*表示