Posts Clipboard Ring in Visual Studio – Tip of Week #3
Post
Cancel

Clipboard Ring in Visual Studio – Tip of Week #3

When you copy and paste text in any application, you are usually limited to copying and pasting one item at a time. If you want to copy two separate sentences, you have to copy the first one, paste it, then come back and repeat this for the next sentence. This can become tedious when you have 10 different things to copy and they reside in 10 different places in the document. You end up switching back and forth between the two documents 10 times, once for each sentence you want to copy.

The clipboard ring eliminates this limitation. The clipboard ring allows you to cut or copy up to 20 selections and access them using a keyboard shortcut. Here is the process for using the clipboard ring:

  1. Copy (Ctrl-C, Edit.Copy) or Cut (Ctrl-X, Edit.Cut) up to 20 text selections, one after the other. These selections are organized as a last-in-first-out (LIFO) stack. That is, the last item you cut or copy will be the top item on the clipboard ring.

  2. Press Ctrl-Shift-V to paste the first selection (the item on the top) from the clipboard ring into your document.

  3. If you don’t want to paste the first selection, press Ctrl-Shift-V (Edit.CycleClipboardRing) again, and the first thing you pasted will be replaced with the next selection from the clipboard ring. For example, if you wanted to paste the fourth item in the clipboard ring, you would simply press Ctrl-Shift-V four times. If you want to paste the same item more than once, simply pressing Ctrl-V (Edit.Paste) after the first time will work, since it will now be the current item on the clipboard.

Instead of moving between two documents a number of times, copying and pasting different selections, you can first copy all of the selections from the first document, then go to the second document and, using the clipboard ring, paste all of those selections. The clipboard ring also comes in handy when you have two or more separate things that you need to paste multiple times; using the clipboard ring, you can switch back and forth between these items easily.

You can also view the current contents of the clipboard ring by selecting the Clipboard Ring tab in the Toolbox dialog. This tab, shown in Figure 2-1, displays all of the selections currently living in the clipboard ring and allows you to drag the selections to paste them into your document.

 

While the Clipboard Ring tab is a good way to get a better understanding of the clipboard ring, it is not as efficient as the shortcut keys. Visual Studio .NET 2003 users will find that the Clipboard Ring tab is absent in Visual Studio 2005, so it is best to use the shortcut keys instead of the Toolbox tab.

This post is licensed under CC BY 4.0 by the author.