2016-12-14 by Vladimir Schneider

Paste From History: A Power User Feature

I have been using JetBrains IDEs, mainly PhpStorm and IDEA, for over two years. Practically glued to the keyboard and screen for the better part of the day and I am still discovering amazing features as I peruse the code for some functionality I want to implement in one of my plugins.

The latest discovery is the power house of a feature in the Paste from History dialog. As I was writing the enhanced version that would show me detailed information about the caret selection stored with the clipboard data, I tried to copy text from the dialog’s content preview. I figured it is just an editor in read only mode, copy to clipboard should work.

Nothing happened. I mean no errors but the content list in the dialog did not budge. On a hunch, I suspected that it did not occur to the author that someone will copy from the viewer to create new content. Close the dialog and re-open it. Voila! The copied content was indeed on the clipboard.

That is one hell of a feature to know and use. This means that when I want to paste something but don’t have the text I need isolated, I can just select a portion of what is there and copy it, creating just the right text for pasting.

I also discovered that I can select multiple entries from the history list and they will be combined into a single paste operation. That too is a game changer. I used to go through code and copy snippets I needed, then wasted my time pasting them one at a time from the history list.

The keys 0-9 are used as shortcuts to select and paste one of the first 10 entries in history. Nice to know. Useful when you don’t want to reach for the mouse or manually move down the list to the right entry.

All that was missing from all this amazing functionality, in my opinion, is a little spit and polish like:

  • ability to re-arrange content, including reversing the order.

    • added by using the move line up/down short cuts to move selected entry or entries up or down. When multiple, non-contiguous entries are selected, the first key press will move them so they are contiguous. Thereafter, up moves them up and down moves them down.

    • when the move line up key is used with the block already at the top of the list, reverse the order of selected entries.

      I often go top down and copy snippets I need to put together in a new function. When it comes time to paste them, they are in reverse order. This lets me correct the order before pasting.

    • similarly for the move down key, if the block is already at the bottom, reverses the order of selected entries. Usefulness of this is debatable but I added for symmetry.

  • update the history list if clipboard content changes, like when you copy from the preview

    • done, nice to have feedback that copy from preview worked and have the entry so it can be combined and used as a new source for copy to clipboard.
  • preserve caret information stored on the clipboard when combining multiple entries. This allows me to use multi-caret select and copy on several disjoint blocks of text and then combine them into one multi-caret content block for pasting.

    • done, now combining entries does not lump them into single block of text, but allows using the combined block with multi-caret paste operations. Saves time when the text I need is assembled from several disjoint locations in the source.
  • add a button to paste content and re-create carets that were used to create it. I do this quite often. Up to now, I used to paste and have to create the carets manually. May not seem like much but do it hundreds of times in a day and the seconds start to add up.

    • done, very useful. Takes a lot less manipulation because when multi-caret text is pasted, automatic code re-formatting does not kick in to indent every other line, messing up alignment and needing a Move Caret to Indent to put carets in the right location for editing.
  • add some hint text to let others know of what is possible with clipboard history, I could have used this information before I discovered it in the code.

    • done, simple text with a checkbox to turn it off to save space.
  • and last but not least, since the preview is a full fledged editor in read only mode, you can use multiple caret select and copy to “extract” multi-caret paste ready content from a block of text. Plenty of times I used to paste the block only to extract what I needed for multi-caret paste, then undo to clean up the file. It was never necessary. It can be done right in the paste from history dialog.

    • done, adds a whole dimension to how I can re-use text already on the clipboard without having to copy it in just the right format from the text in the original file.
  • allow the “paste with carets” button to become “duplicate and paste” when the dialog is opened by the Duplicate Line or Selection for Clipboard Carets action, to save an extra key stroke.

    • done, already gotten used to using this instead of the two step: duplicate and then manually paste.

All this flexibility made me change the way I work to make it even more efficient with less distractions to locate the original text when I need to copy a part of it. I already have it in the clipboard history. I can copy just the right part without stepping out of the dialog.

Here is the end result in the latest Mia Version 0.8.3 release:

 



Constructive comments and suggestions are welcome. I can also be reached me at vladimir@vladsch.com