Did you know... You can Right-drag code to do a Move or a Copy? - #170
Today’s tip was submitted by a blog reader. I had no cluethat you could do this.
Select a line of code, and then right- drag that line to anywhere within your editor (or into another editor window). Then you’ll get this little menu popup with the options of "Move here, Copy here, Cancel."
I love little tricks like these, especially when i never knew it existed. We should play a game called "Stump the Sara" and send me your most obscure IDE tricks. Since i only worked on VS Core, it can only be generic IDE features not tied to any specific language.
Technorati Tags: VS2005Tip,VS2008Tip
Comments
Anonymous
March 12, 2008
It's always nice to learn something new. I always use cut-and-paste, but drag-and-drop seems just a bit more efficient. Thanks for the tip!Anonymous
March 12, 2008
Hey Now Sara, This one is realy neat, I never knew about this one. It's quite useful too. Also I saw a post recently about your sessions on CodePlex & Tip of the day. Hope they go or have gone well. CodePlex is a really great site, I've been using it more & more lately. as always thx 4 the info, CattoAnonymous
March 12, 2008
This tip works for almost any windows application as far as I know.Anonymous
March 12, 2008
Nope...didn't know that one either...although it makes sense. It's the same behaviour as when you drag an icon with right button...only contextually correct. One thing I love about Windows...it's consistent if nothing else. That and the ability to do anything four different ways!! :)Anonymous
March 12, 2008
Maybe this is too elementary, but the same dragging operation can be done without incurring the usability "penalty" of dealing with a redundant context menu. Left-dragging a selection of code performs a "move" -- unless you hold the Ctrl button while dragging, in which case the operation changes to a "copy". A [+] is added to the the mouse pointer to indicate such. Dragging to copy a selection actually works between disparate editors in many cases. E.g. I can copy code from the IDE over into this comment editor in Firefox: using System; using System.Collections.Generic; using System.Management;Anonymous
March 12, 2008
Normally I don't use the drag drop except to avoid over writing what is in the clipboard. (Don't like taking hands off the keyboard to go to the mouse... It's SOOO time consuming! The clipboard benefit is the point that I find really useful! Using the left button (with control for copy) is really neat! "Stump the Sara": Hope your not running out of ideas ;)Anonymous
March 12, 2008
I didn't know that right click one but I've been using the ctrl-drag (with left button) to copy and just drag to move for a long time, it's a great shortcut for copy-pasting ! For quick replacement of several single words like a variable name I also like the fact that ctrl-click selects an entire word, so if I want to replace every occurence of a var name in a function, I hold the ctrl key down, and do a click-and-v on every var name I want to replace. It's pretty fast once you get used to it.Anonymous
March 13, 2008
Thanks for reminding me of this feature...I'll start using it again immediately! Also, works for Visual Studio 2005.Anonymous
March 13, 2008
JDM beat me to it. You can use CTRL while dragging to avoid displaying the context menu. A tip: This doesn't use the clipboard, so, if you need to copy some text but doesn't want to lose whatever you have in the clipboard, you can drag-copy.Anonymous
March 16, 2008
Oogh. A lot of the programmers I know would be better off if copying code were made harder, not easier. :)Anonymous
March 28, 2008
Many text-editing "places" in Windows does this, and you can even do it with items in folders or on the desktop. I discovered this one myself by accident; a book fell on my mouse's right button and caused it to slide slightly, revealing this little popup menu...!Anonymous
April 08, 2008
Is there a way to highlight multiple lines of code and then indenting or unindent all at the same time.Anonymous
April 09, 2008
Due to the simplicity of the answer I'm not sure if this is what you wanted to hear?
- Select multiple lines of text with the usual mouse drag, or the keyboard using SHIFT+up or down arrow keys
- Press TAB to indent or shift+TAB to unindent the selection Incidentally, you can also select a block (square) region of text in Visual studio or Word by holding the ALT key down then dragging over the area with the mouse.
Anonymous
April 11, 2008
The comment has been removedAnonymous
April 11, 2008
I'm inclined to think this is OS level functionality rather than VS or Word specific - I've tried it successfully on third party apps. Does that nullify it from the Stump Sara game since it's below VS core? Also: Clicking and holding the left mouse button for a second or two activates the same feature. And thanks for the ALT+click for selecting a rectangular area - that's nice! I'm sure to find that useful in SQL Server, my bread and butter.Anonymous
April 15, 2008
WOW! That's what i call a genious feature!! This blowed my socks off my feet! You stupid americans...Anonymous
April 16, 2008
The comment has been removedAnonymous
April 23, 2008
The comment has been removedAnonymous
May 10, 2008
The comment has been removed