Sunday, February 15, 2009

Visual Studio 2005 IDE Hot Tips

Recession..2009 has just started, but I am ready to bet my limbs that when Google's Zeitgeist will come up at the end of the year, this hitherto unheard entry will beat everything else to the top spot... For a generation brought up on excess of every kind, the current economic crisis has served a rather rude jolt...pink slips are flying thick n fast and you never know when one will be coming your way..guess its time to put the brakes on fun(temporarily ofcourse) n work a few extra hours...n talking of work, it often helps to have a good grasp on the IDE that you use for coding..

I am using the Visual Studio 2005 IDE for some time now(for C,C++ work)..spoiled silly by Vim all my academic life n career, VS2005 seemed rather cumbersome initially..but after spending some time with it and with generous help from Google queries, I was able to compile a few nifty little tricks, which has made life considerably easier since then..so here's jotting down a few of my personal favs...will be very glad if they help you save some precious programming minutes..

1. You want to view a source file, but dont know where to look..coz the project tree in Solution Explorer and directory structure in vob are different..well, no worries..here's the trick...

a. type CTRL+ /

b. it will activate the Find combo box on the Standard Toolbar...with the symbol ">" prepened.

c. type "of filename".

d. you will get a dropdown list of matching filenames..select the one you wish to check n hit ENTER..voila !!

2. You have a file open and you want to see its location in Sol. Exp. tree..here's how..

a. go to Tools->Options->Project n solutions->General.

b. tick "track active item in solution explorer".

c. open a file in the IDE..n go to Soln. Exp...the file will be highlighted.

3. If you want to see a function/object/variable definition, press F12 on it...you can use CTRL+ - to come back where you hit F12...you can use CTRL+ - also to move to previously navigated code snippets...use CTRL+SHIFT+ - to navigate in opposite direction.

4. If you use a small monitor, you can go to full screen mode using "Shift+ALT+ENTER"...press same combo again to return to normal mode.

5. I often keep Sol Exp in auto hide mode..it can be brought up using "CTRL+ALT+L"..similarly Output window can be brought up using "CTRL+ALT+O".

6. Use CTRL+F3 to search for a word in a file(no need to copy the word, type CTRL+f and paste the word)..use F3 to move forward..use SHIFT+F3 to move backwards..

7.Use SHIFT+F12 to find all references of a variable/function...use F8 to move.

8. Use CTRL+i for incremental search..much better than CTRL+f (when you dont remember the exact word).

9. Use CTRL+SHIFT+f for bringing up Find in Files dialog box.

10. Use CTRL+SPACE for auto-completion of a word.

11. If you are a mouse-hater like me and will like to have some additional functonality through keys, there's help. Go to Tools->Options. Select Environment->Keyboard. Type in the functionality you want in "show commands containing" to get a list of matching commands. If already a shortcut is there, it'll be shown in "shortcuts for selected command". To assign a new shortcut on the selected command, put cursor in "press shortcut keys" and press your combination.

12. A couple of performance tricks, since VS2005 is not the nimblest IDE...

a. When you start VS2005, it shows some latest VS related news from its website..if you are not particularly interested in them, you can load an empty environment(which is faster)..go to Tools->Options->Environment->Startup. Tick "show empty environment".

b. You can also disable Intellisense, if you use other IDE for coding(like Source Insight)..as Intellisense consumes an awful lot of resources. Go to VS2005 installed directory in your machine..and remove or rename the dll "feacp.dll" present in below path..

Microsoft Visual Studio 8\VC\vcpackages

13. You can use word-wrap if you often encounter long lines of code and need to scroll horizontally...go to Tools->Options->Text Editor->All Languages n tick word wrap.

Well, thats it...there are myriad other such shortcuts and I have compiled and put here only a few which are not well-documented, but can be of immense help...you are welcome to post any other which you found useful...n I will be try my best to help if you have some specific query in mind..Happy programming and death to Recession. Amen !!