Welcome to MSDN Blogs Sign in | Join | Help

Sara Ford's WebLog


My adventures embracing open source on CodePlex and at Microsoft

News

Did you know... you can drag and drop code to a new location? - #033

I tend to be more of a keyboard user, probably because I'm too lazy to reach all that way for the mouse.  When I first saw this functionality, I was surprised because it is just not something i would intuitively think of, but of course it makes completely sense once the "oh, I haven't seen that before" wears off.

Dragging Code Illustration

Select the code block you wish to move by holding down the primary mouse button, and then drag the mouse pointer to the desired location.  To copy code to the new location, hold down the Ctrl key.

Not impressed?  You can also drag and drop code to a different file.  Drag the code above the desired file tab, as shown below. 

Drag code over the desired file tab to switch to that file

Although you'll get the mouse "can't drop" pointer, the editor will switch to that file.  Then just mouse down, and you'll see the "drag and drop" pointer again.  Good times!

Technorati tags: ,
Posted: Monday, September 10, 2007 3:00 AM by saraford

Comments

Aaron said:

Is there a way to prevent html reformatting on drag-drop?  In VS2005 if I copy-paste, it preserves my formatting.  Drag the same block and it will for example take tr td (content) /td /tr and split it onto 5 lines.  If I drag a server tag, it will re-order the properties (ex a validation control).

# September 10, 2007 8:44 AM

Jason Haley said:

# September 10, 2007 10:14 AM

Jason Haley said:

# September 10, 2007 10:16 AM

Peter Ritchie said:

I couldn't live without that drag-n-drop from one file to another...

# September 10, 2007 1:08 PM

Peter Ritchie said:

Aaron, does changing Tools/Options, Text Editor/HTML/Miscellaneous, "Format HTML on paste" make a difference?

# September 11, 2007 10:56 AM

Sara Ford's WebLog said:

Following yesterday's tip theme of code relocation, you can cut and paste a collapsed block of code,

# January 15, 2008 12:38 AM

Visual Studio 2008 ワンポイント said:

コードの移動に関する 昨日のワンポイント に続いて、折りたたまれているコード ブロックをカット アンド ペーストする方法をご紹介します。内部のコードは一切変更されません。これは完全に予想どおりの動作ですが、私は試そうと思ったことがありませんでした。

# July 7, 2008 4:02 AM

Visual Studio 2008 ワンポイント said:

私は、マウスを操作するのが面倒なせいか、キーボードを多く使います。この機能を最初に見たときも、私にはちょっと考え付かない方法に驚きました。もちろん、慣れてしまえばこれほど便利なものはありません。 マウスの左ボタンを押しながら、移動するコード

# July 13, 2008 11:36 PM
New Comments to this post are disabled
Page view tracker