Opinion: Five Things You Might Not Know About Visual Studio
[In this reprinted #altdevblogaday-opinion piece, Gameloft 3D programmer Gustavo Samour provides several useful tips for Microsoft Visual Studio to help you find your way around the editor.]
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.
(Find in Files)
(VS2008 Call Browser)
(VS2010 Call Hierarchy)
(New Vertical Tab Group)
[This piece was reprinted from #AltDevBlogADay, a shared blog initiative started by @mike_acton devoted to giving game developers of all disciplines a place to motivate each other to write regularly about their personal game development passions.]