3

I know you would normally enter into vimdiff mode from the terminal with vimdiff file1 file2. However, I frequently find myself already in vim with multiple different splits, and I'd like to run vimdiff on two specific splits, and then turn vimdiff off.

How would I go about this?

N.B. there might be other splits in my vim session that I don't want to be comparing. So I might have 4 vertical splits and I want to run vimdiff on split 1 with split 3, look at some differences, and then turn the diff off.

7

The command is called :diffthis. It must be executed in every window you want to add to the comparison.

The inverse is :diffoff which exits diff mode in the current window. To exit diff mode in all applicable windows add a bang: :diffoff!.

| improve this answer | |
  • The cod mapping from tpope's unimpaired can be handy. – mMontu Mar 12 at 13:07
  • @mMontu It maps exactly to diffthis / diffoff. So it's useful if you're already using vim-unimpaired. Otherwise, it's not a problem to create such mapping yourself. – Matt Mar 12 at 14:39
  • @Matt glorious - thank you, this works a treat. – Aeroblop Mar 12 at 15:22
  • 2
    To quickly accomplish this in your splits, you can use :windo as in ":windo diffthis". – jpheldson Mar 12 at 20:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.