Visual Studio IDE Tips and Tricks - Copy/Paste E-mail

Some helpful tips and tricks that will help you get the most out of moving text around in the Visual Studio IDE.

Introduction

There isn't a huge variety of books out there that focus on being productive with the Visual Studio IDE (as opposed to the programming languages themselves). Here are a few tips that I've learned over the years that I've come to find very useful. Also, I've dome some of the research for you. Here are a few great Visual Studio IDE books, along with some more advanced topics and references.

Visual Studio IDE Books - Click to learn more
Visual Studio .NET Tips and Tricks
$14.21 (11% savings)
Professional Visual Studio 2005
$8.98 (82% savings)
Microsoft Visual Studio 2005 Unleashed
$13.86 (77% savings)

Advanced .Net References - Click to learn more
Professional .NET Framework 2.0 (Programmer to Programmer)
$5.75 (86% savings)
.NET Framework Standard Library Annotated Reference, Volume 1: Base Class Library and Extended Numerics  Library (Microsoft .NET Development Series)
$71.78
.NET Windows Forms in a Nutshell
$24.97 (44% savings)
.NET Framework Solutions: In Search of the Lost Win32 API
$43.78 (27% savings)
Inside Microsoft  .NET IL Assembler
$35.91 (28% savings)

Block Select

Say you have list of declarations like below, and you want to copy and re-use only the variable names later in the code -- perhaps when they're initialized. How do you do it? You might think you have to copy all the lines, paste, and then start deleting all the data you don’t need -- or search/replace to get rid of the data you don’t need.

private int _NumSnakeheadFish = 0;
private int _TotalToothCount = 0;
private int _ToothIndex = 0;
private int _FirstDigitOfPi = 0;
private int _PoundsToLose = 0;
private int _Age = 0;
private int _NumAngryMen = 0;
 

Here's the trick: Hold down Alt, then click on the "_" in front of NumSnakeheadFish, and drag down and to the right until only all the variable names are selected... then Ctrl-C to copy, and Ctrl-V to paste elsewhere. This works for a lot of Windows apps.

Clipboard Ring

Say you have a bunch of little snippets of code you want to move from one part of the code file to another. We’re so used to the standard clipboard functionality that you might think you’re forced to scroll-up/copy, scroll-down/paste, repeat, repeat, repeat. One option to make this go smoother is to split the window by pulling down the little handle at the top of the vertical scroll bar. Position the top window for copying and the bottom for pasting.

Another option involves the mysterious panel in the Toolbox called the Clipboard Ring. Try this: Copy some code with Ctrl-C, then move on to copy a different portion of code with Ctrl-C, then again. All three bits of code are stored in the Clipboard Ring – you can recover them by positioning the cursor double-clicking the Clipboard Ring entries, or alternatively by positioning the cursor and pressing Ctrl-Shift-V, which when used repeatedly, cycles through all the Clipboard Ring entries. Press Ctrl-V to repeatedly paste the selected Clipboard Ring item.

Line Copy, Cut, & Paste

The IDE applies copy, cut and paste operations by default to the entire line your cursor is on. This means you don’t have to select the line to copy or cut it. To try it, put the cursor anywhere on a line,

Use Ctrl-X to cut the line, move the cursor to a different line (anywhere on the line), and use Ctrl-V to paste the line. If you cut the whole line, you’ll paste the whole line, and the IDE will maintain the integrity of both lines (i.e. the paste won’t dump the text out at the cursor location if it’s in the middle of the line – it’ll move the line out of the way first.)

Paste & Select

If you want any pasted text to be selected when you paste it, use Ctrl-Shift-V.

 

Offers

Google Tools

Gmail Docs Code Finance Maps Calendar

More Offers