Help me go to college!
New Discussion Forums!
Join the brand new discussion forums today and help the community grow by contributing
your questions, comments, ideas, and expertise!
Join now!
Google Search
|
Visual Studio IDE Tips & Tricks - Copy & Paste Edition Some helpful tips and tricks that will help you get the most out of moving text around in the Visual Studio IDE.
All images, text and code is ©1995-2008 by Alex Franke. All rights reserved. Published: Oct 24, 2006 Updated: Oct 26, 2006
In this article:
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.
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.
|