Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio debug jump out of loop

Tags:

I know about basic features of visual studio debugging. F10, F11, Shift+F11, Ctrl+F10.

If I am inside a for loop is there a way of stopping right after the loop is completed? Right now the way I am doing it is to manually go to the location after the loop and press Ctrl+F10. Is there a better way of doing this?

like image 318
skeept Avatar asked Apr 22 '13 15:04

skeept


People also ask

How do I skip a line while debugging in Visual Studio?

You can also click on the line you want to skip to and hit Ctrl+F10 (Run to Cursor). It will jump directly to that line.

How do I stop a Visual Studio Debug session?

To end a debugging session in Microsoft Visual Studio, from the Debug menu, choose Stop Debugging.

How do I close a run and Debug code in Visual Studio?

VS Code maintains a debug session while the program is running, and pressing the Stop button terminates the program.

How do I get out of loop while debugging?

Direct link to this comment As a user I would suggest the following: make a hotkey to exit the loop in debugging mode, for example ctrl-shift-F11.


1 Answers

There is no dedicated "Step Out of Loop" command in Visual Studio. "Step Out" (Shift+F11) works only for functions. There are only two options that I can think of:

  1. Like Brian suggests, there is Run to Cursor, which has been there at least since VC++ 6. This is what you're already getting with the Ctrl+F10 keyboard shortcut. I use this literally all the time while debugging; it's an extremely useful tool. I don't really understand why you think this is a lousy way of doing it, or why you think there should be a "better" way.

  2. You could set a simple breakpoint on the line of code immediately following the loop. This is relatively simple if you use the keyboard shortcut F9. But you still have to navigate to the appropriate line of code, so you might as well use Run to Cursor.

If you're working in a C-derived language, your loops probably conclude with a }. So you could use the Ctrl+] keyboard shortcut to move to the matching brace in the source file if your caret is at the loop's opening brace. That might make navigation easier. It certainly can help avoid moving your hands over to the mouse, killing precious seconds.

* Note that keyboard combinations are subject to change, depending on how you have configured your Visual Studio environment.

like image 101
Cody Gray Avatar answered Jan 03 '23 11:01

Cody Gray