Published - 7 years ago ( Updated - 7 years ago )
Vimdiff can be used to open multiple files on the command line..
Assume that a file has already been opened, so:
Here is a common cheat sheet for vimdiff:
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.
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 splitHere 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
No Comment
Post your comment