Saturday, April 27, 2013

Tip 2.6: You can display guidelines in the editor to help format your code

"Visual Studio Tips, 251 ways to improve your Productivity in Visual Studio", courtesy of 'Sara Ford'

Sara Ford's Blog



Sara Aside

The most popular tip on her blog is the one about guidelines. She thinks it is so popular because it was one of her very first tips about Microsoft Visual Studio many, many years ago. She's had a lot of people thank her for including that tip in her blog, but when a random developer stopped her in the hallway to thank her because he wrote the feature, that took hallway conversations to a new level. He had moved to another area of Visual Studio many years before my writing the tip, so he was very excited to see his feature get some public attention. She think one of the hardest things for any developer is to spend time coding a feature that never gets into the hands of a customer.

Important

To enable guidelines, you need to modify your registry settings. Please be aware that you use guidelines at your own risk and should do so only if you are comfortable modifying your registry settings. You will need to restart Visual Studio after modifying the registry for the changes to take effect.
Go to HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\10.0\Text Editor. Create a String (RG_SZ) key called Guides. The value is in the format of RGB(x,y,z) n1,...,n13, where x,y,z are the RGB values and n is the column number. You can have at most 13 guidelines. For example, RGB(255,0,0) 5,20 will put two red guidelines at column positions 5 and 20, as illustrated here:



Happy Programming! =)
Posted by Nils-Holger at 2:03 PM with 681 comments.

Friday, April 26, 2013

Tip 2.5: How to quickly comment and uncomment code using keyboard shortcuts

"Visual Studio Tips, 251 ways to improve your Productivity in Visual Studio", courtesy of 'Sara Ford'

Sara Ford's Blog



Ah, it really is the simple things in life, isn't it? Use Ctrl+K, Ctrl+C to comment code and Ctrl+K, Ctrl+U to uncomment code. All the default development settings have these commands bound to these keyboard shortcuts. You can find these commands under the Edit–Advanced menu as shown here:



Happy Programming! =)
Posted by Nils-Holger at 12:04 PM with 837 comments.

Thursday, April 25, 2013

Tip 2.4: How to swap the current anchor position in the editor

"Visual Studio Tips, 251 ways to improve your Productivity in Visual Studio", courtesy of 'Sara Ford'

Sara Ford's Blog



Ctrl+K, Ctrl+A will swap the current anchor position.

Sara Aside

To test Emacs emulations, she decided to write all her test cases in Emacs mode. (Emacs is a text editor, similar to Visual Studio. For details, see the Wikipedia article http://en.wikipedia.org/wiki/Emacs.) What was interesting is that she seemed to swap the anchor position all the time (using the appropriate shortcuts in Emacs mode); yet whenever she wasn't in Emacs mode, she never did this. She thinks it was just the way she was trained in college to think about the Emacs editing experience that made her want to swap the anchor position.
Cursor position before swap:



Cursor position after swap:



Happy Programming! =)
Posted by Nils-Holger at 1:09 PM with 1694 comments.