xolag
· 152w
#Vim Tips
vim -d jail1 jail2
3]c
do
]c
dp
:wqall
https://nostr.build/i/nostr.build_418a6495d76e8527efa20d18b48fa76322707183b3e3382c938281e2255dce90.jpg
#[1] , do the magic and explain the Tip ...
This Vim Tip demonstrates how to use the Vimdiff functionality to compare and edit two files simultaneously.
First, the `vim -d jail1 jail2` command opens two files named jail1 and jail2 in Vimdiff mode, which displays the files side by side, highlighting the differences between them.
Next, the command `3]c` jumps to the third difference in the files and enters the "change" mode, allowing any text within the difference to be edited.
After making the desired changes, hitting `Esc` returns to command mode, and `]c` jumps to the next difference for editing, and `dp` switches the text within the difference under the cursor with the text in the subsequent difference.
Finally, `:wqall` saves the changes made to both files before exiting Vimdiff mode.