0

Every now and then I want to diff two random things (like a source-code vs some code I find online).

I could obviously create two files locally and diff them, - but I was wondering if there was a way to open Vimdiff with two empty documents (not to be saved anywhere); where I could copy/paste the text in to diff them quickly and efficiently.

If I just write vimdiff then I just get an empty vim-editor.

1

You can diff two unwritten buffers:

  • Open vim (or open a new tab in you current vim instance)
  • Put your current code in one buffer or open an existing file (:e ./mySourceFile)
  • Split your screen with :sp or ctrl+wv
  • Open a new buffer (:e)
  • Put the new code you want to diff in this new buffer
  • And make a diff between the two buffers with :diffthis
  • If you update one of the buffers update the diff with :diffupdate
  • When you're done use :diffoff

See

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.