Search
Tuesday, February 27, 2001 ..:: Home ::.. Register  Login
   Calendar  
     
  
   Search  
     
  
   Disclosure  
     
  
   TechTidBits (Blog)  

VS Tips'n'Tricks: Anchor Swapping and Unwrapping Lines

Feb 12

Written by:
Thursday, February 12, 2009 9:13 PM  RssIcon

Unless you're Sara Ford or Scott Cate, I'm pretty confident you haven't heard of these two features, Anchor Swapping and Deleting Words, but they are pretty cool.  Read on for more details.

Sara Ford's MS VS Tips, 251 Ways to Improve Your Productivity

Sara Ford and Scott Cate have their own blogs which talk about Visual Studio tips'n'tricks.  Sara's even gone so far as to write a book!

Regular readers will know I'm a keyboard monkey with VS.  A while ago I read about two cool features VS has but as the old adage goes, if you don't use it, you lose it. :<

Well, today was one of those cool days where I read a few links from Scott's blog and remember two cool tips/shortcuts I read about from Sara but never really understood their usefulness, until I saw Scott's video (Sara has the text/written version while Scott usually has the matching vids).

Swapping Anchors

The crux of this tip was lost on me until today!  If you're always perfect with selecting your code to cut'n'paste, then you can ignore this, but if you're not and you sometimes "miss your shot" with your cursor/mouse, this will help! 

Let's take the example below when I/you started selecting text from line 13 but you started in the middle of the line, then using the mosue of SHIFT+arrow keys, selected up to line 7....then you realize, crap, I wanted more of line 13!  What next?  Chances are you'll start over again!  Not anymore!  Hit CTRL+K, CTRL+A will move your "anchor" point (the "I" beam) to the other edge/end/anchor of the selected text whereby you can continue with your SHIFT+arrow keys for your text selection!  Very cool IMHO.

Swap anchors when selecting text

Deleting Words (can also be known as/used for Unwrapping Lines)

Technically you'll find these listed as

CTRL+BKSPCE = WordDeleteToStartand and

CTRL+DEL = WordDeleteToEnd 

in VS (assuming you're using the C# keyboard layout).  Now that's what I've read/seen/tried and it's pretty boring.  "Yawn, back to work!" you say?  I said that too!  Until today when I saw Scott use this in a slightly differen way.

Let me setup the scenario.  You're refactoring some code, and you have a bunch of white space on the next line from where you are (like below) and you want to "unwrap" that text up to where you are now (hey, I agree this example is made up, but it illustrates the point, so go with me on this one :>), you just hit CTRL+DEL and you'll delete all the whitespace (to the right including the CR/LF and continuing with the whitespace on the next line).  This way you can quickly reformat for loops for example!

Unwrapping lines of code

I hope you've enjoyed this little distraction from your regularly scheduled workload!  And with a little bit of practise, I hope you too will be able to enjoy less time fidgeing with the code and more time concentrating on what you want to do and not how you're going to do it. 

 

Resources

Scott's Video on Anchor Swapping

Scott's Video on Unwrapping Lines

Tags:
Categories:
Location: Blogs Parent Separator TechTidBits

Your name:
Gravatar Preview
Your email:
(Optional) Email used only to show Gravatar.
Your website:
Title:
Comment:
Add Comment   Cancel 
     
  
Copyright 1999-2012 by PCHenry.com   Terms Of Use  Privacy Statement