Prabir's Blog

where the tech matters...

Visual Studio Tips and Tricks - II

May 23
by prabir 23. May 2009 16:40

There are at times when you would like to format your code properly, especially with xml stuffs including html tags. Indention provides you with much clarity in your code. Just looking at it you can understand much of it. Even makes your debugging easier. Its really an important part of code organization.

So how would you do it in a traditional way. Tab..Tab.Tab.. oh i’m wrong shift + tab. Well, those are gone with the old ages. Now its even better than before. Ctrl + k, Ctrl +  d. What you do is Press Ctrl + K and then after some time press D while holding Ctrl. Don’t wait too long. You’ll get used to it. Its just a matter of practice. After all practice makes a man perfect.

It works with almost any languages, whether it is xml files, html, C# or .aspx files.

In short I like to call this Ctrl + kd. After finding this magical sequence of keys, it has really help me speed up my coding time.

imageBefore Ctrl + KD

image
After Ctrl + KD

As you can see, it even automatically moves excess text to you next line so that it can be fit on you screen easily.

For more articles on tips and tricks refer here. Or you can also access the page from the right menu under Page List heading

If you enjoyed this post, make sure you subscribe to my RSS feed!

Tags: , , ,

Visual Studio Tips and Tricks - I

May 22
by prabir 22. May 2009 01:22

As a developer you would always want to write your code faster. But do you think practicing from your Typing Tutor is the ultimate solution. Nah. There are better ways to do it, and some of them is learning your IDE (Integrated Development Environment). This can definitely simplify your coding and automatically speed of your coding. Its quite impossible to list all the tips and tricks of Visual Studio out here, so I have thought of creating a series of blog post which you can latter refer from here.

In this first series, I will basically teach you how to automatically insert the namespace at the using block on the top of your .cs code.

The traditional way to basically insert the namespace would be to navigate to top of your cs code and type using Company.SomeNamespace. Well first of all just using your mouse to navigate at the top, or typing it or even using the shortcut ctrl + home to go to the top already loses lot of time. (well this is computer stuff, so even a second is too slow). If you actually look carefully you will see and underline short of character found under the last letter of your word like this one image. One of the way is to use your mouse and hover over the underline and the following menu would appear, or just use Ctrl + . (Ctrl + period) and press enter as the top one which is System.Diagnostics would be automatically highlighted. This would automatically add the namespace to the top of your .cs code.

Visual Studio 2005

This seems to work perfectly well with Visual Studio 2008 but seems to be a bit broken with Visual Studio 2010 Beta 1. I have posted a feedback about it to Microsoft to fix it. Hope they fix it by RTM. Anyways below is the screenshots of how its done is VS2010 Beta 1. The problem is that in VS2010 beta 1 doesn’t automatically select the first item in the menu like the one VS2008 does. So, for VS2010 Beta 1 you need to use one more button – down arrow key and then enter key. This bug has already been fixed up in the internal builds of VS2010 and is expected to be in effect from the upcoming version of Visual Studio 2010.

image

For more articles on tips and tricks refer here. Or you can also access the page from the right menu under Page List heading.

If you enjoyed this post, make sure you subscribe to my RSS feed!

Tags: , ,