How can I change the location of a breakpoint in Visual Studio 2017
A

1

10

I've been looking over the internet to find out how to change the location of a breakpoint in Visual Studio 2017 and cannot find any answers. The only answer that comes close is from 2009 and is no longer an option in VS2017.

Most attempts to answer the question involve deleting and recreating the breakpoint. Most of the time that is fine, however if you're dealing with tracepoints or conditional breakpoints which have several options applied to the "breakpoint" you don't really want to delete and recreate it.

I've even seen requests on UserVoice to drag-n-drop the breakpoint to a different line, but nothing that tells me how to do it even without drag-n-drop.

Yes, I know a lot of people say why do you even want to move it? Well sometimes VS2017 just doesn't get that after doing a Get Latest from TFVC, the code has moved but the breakpoint hasn't moved with the code, and I really don't want to recreate the conditional tracepoints. Or maybe I just want to move it for general testing and debugging and focus on a differnt bit of code. Either way, it doesn't really matter why - the question is how.

So how do I change the location of a breakpoint without having to delete and recreate all the options?

Asher answered 19/6, 2018 at 7:25 Comment(1)
Would you please mark your solution as the answer, so it could help other community members who get the same issue. Have a nice day:)Inquiline
A
17

Okay, so maybe I'm just blind, but it was not at all obvious to me.

VS2017 Breakpoint Settings

You see the blue text where it says Location: - that means you can click to edit! (Yes, just like you can click to edit the hit count or message string which are also in blue.)

VS2017 Breakpoint Settings - edit Location

And voila! We can now change both the line number and even the character position of the breakpoint without having to delete and recreate all the options (which is a pain if you have some complicated conditions or messages to output or a lot of breakpoints to move).

Hoping this helps someone because not even the Visual Studio Documentation for Using Breakpoints mentions this!

Asher answered 19/6, 2018 at 7:25 Comment(2)
This is absolutely awesome. I've wanted to do this for months (I use conditional breakpoints a lot to debug a scripting language) and finally decided to Google it and viola! First hit has the answer and it's easy as pie.Robichaud
Absolutely great finding! I use trace points a lot and it's quite a pain to move them manually each time the number of lines before a trace points changes. Having the option to really pin breakpoints to the line of code would be a dream.Piping

© 2022 - 2024 — McMap. All rights reserved.