VS Tips'n'Tricks: Anchor Swapping and Unwrapping Lines
Feb
12
Written by:
Thursday, February 12, 2009 9:13 PM
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 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.

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!

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