Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

What I want to do is: (1) Copy a piece of code and paste into a buffer in Vim; (2) Copy another piece of code and paste into another buffer in Vim; (3) Compare these two buffers directly without saving them into files.

I know this can be done easily with Notepad++. I need to do this quite often, and I want to know if Vim can do this. Thanks!

share|improve this question

With the code pasted into your buffers, go to each buffer and execute


If those two are the only buffers in your vim session, you can execute this one command instead:

:windo diffthis
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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