Getting to know your game development tools takes time, but it’s time well spent. By taking one step at a time and learning from each other, we can all become experts. Here’s a few things you might not know about Microsoft Visual Studio.
1. Find in Files
This is an enhanced version of the Find tool. You can open it by going to the Edit menu, then Find and Replace -> Find in Files. You can also use the shortcut Ctrl-Shift-F. A window comes up, in which you can configure certain parameters. For example, the “find what” field can be an ordinary string, a regular expression, or a wildcard. The “look in” parameter lets you choose whether you want to search the current document, all the open documents, the current project, the entire solution, or Visual Studio’s include directories. You can also search a specific folder and include sub-folders if you want to. Filters can be used to limit the search, by only looking in files with certain extensions, or files with a certain word in their names. Once the search has started, results will begin appearing in one of the “Find Results” windows. Each result shows the full path to the file, the line number where the search term appears, and the line itself; double clicking a result opens the file and places the cursor at that line.
2. Call Browser / Call Hierarchy
How many times have you looked at a function and wondered, “who is calling this function?” Now you’ll know, by using the Call Browser (VS2008) a.k.a Call Hierarchy (VS2010). Just right-click on a function name, then click on Call Browser / Call Hierarchy. A window opens, letting you see who is calling your function, as well as who your function is calling.
3. New Vertical Tab Group
If you’ve ever wanted to look at two documents side-by-side in Visual Studio, but didn’t know how, this one’s for you. If you have at least two documents open, you’ll see an option in the Window menu, called “New Vertical Tab Group.” Clicking on it will add a tab group to the document pane. Whenever you open a new document, it’ll go to the tab group that had the cursor last. Closing all the documents in a tab group will close the tab group altogether.
4. Data Breakpoints
We all know and love breakpoints because they help us debug our software. Regular breakpoints cause the program to break when execution reaches a specified location. Data breakpoints cause the program to break when the value of a variable changes. To insert one of these, your program must be running already, with the debugger attached. Go to the Debug menu, then New Breakpoint, and click on New Data Breakpoint. A window appears, asking three things: the memory address to watch (i.e. &myVar), the number of bytes to watch (i.e. 4 bytes if myVar is a float on a 32-bit system), and the language (C or C++). Once that’s set up, the debugger will break on every line where the variable’s value changes.
Note: Data Breakpoints are only available for native C/C++ code. Also, if you don’t see “New Breakpoint” under the Debug menu, it means you’re probably using Visual Studio with “Basic Settings”. If you go to the Tools menu, then Settings -> Expert Settings, the “New Breakpoint” option should now appear under the Debug menu.
5. Command window
This one was brought to my attention by a fellow AltDevBlogger (thanks Forrest!). Pressing Ctrl-Shift-A brings up the Command window, a console of sorts. It lets you execute menu commands plus other instructions that do not appear on any menu. For example, to see the value of myVar, you type “Debug.Print myVar”. To open a file in the IDE, type “of filename.ext”. To compile, type “Build.Compile”. For a complete list of commands, please check the documentation.
Helpful Links:
http://msdn.microsoft.com/en-us/library/dechx2tz(v=vs.80).aspx (Find in Files)
http://msdn.microsoft.com/en-us/library/h3hf4370(v=vs.90).aspx (VS2008 Call Browser)
http://msdn.microsoft.com/en-us/library/dd409859.aspx (VS2010 Call Hierarchy)
http://blogs.msdn.com/b/zainnab/archive/2011/03/01/split-code-windows-vertically.aspx (New Vertical Tab Group)
http://msdn.microsoft.com/en-us/library/350dyxd0.aspx (Data Breakpoints)
http://msdn.microsoft.com/en-us/library/c785s0kz.aspx (Command Window)