It’s worth getting to know the little features in your favourite IDE. Here’s a neat trick that might increase your productivity a little.

Suppose I want to write a Hello, world! program.


static void Main(string[] args)

{

Console.Write(" world!");

Console.WriteLine("Hello,");

}

Uh oh, I’ve written a ” world!Hello,” program instead. What a muppet! I need to swap those two lines of code around.

There are a few different ways you could deal with this (albeit trivial) problem using a combination of copying, pasting, cutting and deleting, but did you know that you can copy more than one thing to the clipboard at a time into something called the clipboard ring?

Here’s how it’s done:

Select the ” world!” and Ctrl + X, then select the “Hello,” and Ctrl + X (for speed use the keyboard: cursor keys + Shift)

Press Ctrl + Shift + Ins twice, move the cursor to the Write call at the top and then another Ctrl + Shift + Ins twice and the switch is complete!


static void Main(string[] args)

{

Console.Write("Hello,");

Console.WriteLine(" world!");

}

Okay, so this is a trivial example, but the ability to cycle through stuff on the clipboard could be really useful in the right hands. There used to be functionality to show the contents of the clipboard ring but that appears to have been removed from more recent versions of visual studio. There are third party solutions that replace is, but if anyone knows how to replace the Visual Studio version let me know!

 

Advertisements