by Devin Yang
(This article was automatically translated.)

Published - 7 years ago ( Updated - 7 years ago )

Vimdiff can be used to open multiple files on the command line..
vimdiff file1 file2 [file3 [file4]]
But how to open it in vim?
Assume that a file has already been opened, so:
:vert diffsplit 【另一個檔名】
Add vert to represent vertical split, if you only use :diffsplit 另一個檔will be horizontal split

Here is a common cheat sheet for vimdiff:
]c :        - next difference
[c : - previous difference
do - diff obtain
dp - diff put
zo - open folded text
zc - close folded text
:diffupdate - re-scan the files for differences
Vim is an extremely customizable thing, everyone's habits and settings are different,
In the .vimrc file, my habit here is to set Vim's LEADER Key to ","
let mapleader=","

My settings, through ,h and ,l to switch the left and right windows, I believe Vim veterans use hjkl for cursor movement,
If you still use the up and down keys to operate Vim, please try to practice hjkl,
After you get used to it, you will like it, so I use it for Leader Key, and it is quite intuitive to use hjkl.
nmap h h
nmap j j
nmap k k
nmap l l
In addition, when we use do or dp, the entire block is replaced, so how to replace it in a single line:
nnoremap  dp V:diffput
nnoremap  dg V:diffget
A more advanced method that has the opportunity to be used is to select multiple lines for replacement through the V method. After selection:
:diffget
:diffput



 

Tags: vim

Devin Yang

Feel free to ask me, if you don't get it.:)

No Comment

Post your comment

Login is required to leave comments

Similar Stories


vim, macos

Ultisnips requires py >= 2.7 or py3 Bugfix

If you install Vim like me, will there be an error that python2.7 or python3 is required when executing the terminal, but the system obviously has python 2.7? This article explains how I fixed this issue.

vim

Write Code with Command Line's Vim??

If you are a beginner of Vim, do you want to use Command Line Vim to connect to the remote host to write Code? Ok you've come to the right place, please at least consider reading this article. Here is a short video on how to manage cheats...