Thursday, August 5, 2010

Things I Love About IntelliJ IDEA: Buffer History

With IntelliJ IDEA's Buffer History or "Paste From History" (Ctrl-Shift-V), you can copy multiple snippets and have all of them available for pasting later on. There's no special trick to copy things into the Buffer History - everything copied goes in there. To paste something from the History rather than the lastest copied snippet, just press Ctrl-Shift-V to see the list of available snippets. It's great for a couple of different uses.

Firstly, there are those situations where you need to copy multiple snippets from one source and paste each snippet one or more times at some other destination. For example, you might need to copy multiple sections from one file to another file, which would normally require you to copy one section then paste it in the destination, then come back to copy the other section then paste that into the destination. Or you might be building up a unit test and you have to add two separated lines to each test case, which you would normally do by traversing all the tests once to paste the first line and a second time for the second one.

With the Buffer History, you can just copy each of the sections from the source one after the other, then traverse to the destination and paste each section where it should go. No more jumping back and forth between files, and no more need to traverse the one file multiple times to paste different snippets.

Secondly, the Buffer History helps out in a couple of facepalm scenarios that I often encounter and with which I hope you'll sympathise:
#1: "Urr... I need to paste that thing that I pasted in that other file ten minutes ago. What was that file called again?"
#2 "Aw crap. I just hit Ctrl-C instead of Ctrl-V."

If you encounter either of these in IDEA, just hit Ctrl-Shift-V.
Problem solved.
Facepalm prevented.

I recommend increasing the size of the clipboard history to at least 30. (Search for 'clipboard' in IDEA's Settings.) It doesn't cause any problems to have a larger history and having everything you've copied for the last hour still in the clipboard can save quite a bit of searching.

2 comments:

  1. If you use a Mac, LaunchBar does the same thing. I use it so much I no longer use the intellij feature when using the editor!

    ReplyDelete
  2. You can also use ClipX under Windows to achieve the same, it works accross applications.
    I’m sure there’s an equivalent under Linux and Mac.

    ReplyDelete