Using the Immediate Window on Visual Studio

This is a quick tip for visual studio users. It may be that most developers using VS already know this, but I only recently found about the immediate window. The immediate window is useful as a complement to visual C++ integrated debugger, as it allows one to evaluate small C++ (or C#) expressions during debugging. It is the closer you get from having a REPL in C++, using visual studio technology (of course, for people used to Python, Ruby, or Lisp, saying this is almost an insult, but that is what can be done).

To access the immediate window in debug mode one has the following options:

  • Type Control-Alt-I (the fastest way)
  • In the command window, type imme
  • Or find the option “Immediate Window” in the “view” menu (if you are lucky enough, some people can’t find it [1])

Once you have an immediate window, you can type simple expressions. The most useful of them are assignments, so you can easily change the value of a variable while observing its behavior.

You can also use this window just to check the value of data, without the need to call a “watch” or “quick watch” window. It is just easier to type the expression you want to see.

Finally, you can combine this with an unrelated but useful feature: you can move the instruction pointer for the program by drag-and-drop of the instruction pointer (the yellow arrow on VS editor). This can be used to simulate at least part of the “drop-to-frame” feature in Java.


Similar Posts:

About the Author

Carlos Oliveira holds a PhD in Systems Engineering and Optimization from University of Florida. He works as a software engineer, with more than 10 years of experience in developing high performance, commercial and scientific applications in C++, Java, and Objective-C. His most Recent Book is Practical C++ Financial Programming.

2 Responses to “Using the Immediate Window on Visual Studio”

  1. Slight correction. In the command window, type immed. Thanks though! I wouldn’t have found it without this post.

    By John Berryman on Aug 20, 2010

  2. Thanks Its worthy for me.

    By Abdullah Musani on Mar 8, 2012

Post a Comment