A margin which exposes .Net Regular Expressions search and replace capabilities on a given code window. Toggle the margin by Alt+r. Navigate to next search by Alt+n. Navigate to previous earch by Alt+p. Escape key hides the margin and set focus back to the code window.
"replace all" seems not to do anything some of the time. I haven't spent much time testing it but it seems to possibly depend on whether the regex contains line start and end markers?
Seems like a great extension otherwise, BTW.
I really like your addin, but is there any way to change background colour of margin?
Also can you add navigation to previous/next search results by using Up/Down keys when Find Next textbox is in focus (I think that this feature will be very useful)?
One more thing - can you move highlight marker under selection layer? It will look more "natural".
[Order(After = PredefinedAdornmentLayers.Outlining, Before = PredefinedAdornmentLayers.Selection)]
Thanks for downloading my extension! I love your idea about up/down arrow navigating to find results - I'll code that up. Also, there is no way to change the background color right now, perhaps I should pick a system grey to blend in more with the shell background. Do you have any suggestions?
Also, right now I'm using classifier tags to highlight the matches, which is why they are ontop of the selection layer. I'll change to using textmarker tags, which should be behind the selection layer.
Hey, Fiona. I have only been using your add-on for 5 minutes, so I can comment on it yet, but I got an exception and I thought you should know of it. Here it is, taken from ActivityLog.xml:
System.NullReferenceException: Object reference not set to an instance of an object.
at FionaFung.RegexMarginPackage.RegexTagger.FindMatches(ITextSnapshot textSnapshot)
at FionaFung.RegexMarginPackage.RegexTagger.textBuffer_Changed(Object sender, TextContentChangedEventArgs e)
at Microsoft.VisualStudio.Text.Utilities.GuardedOperations.RaiseEvent[TArgs](Object sender, EventHandler`1 eventHandlers, TArgs args)
It appeared when I moused over a "dot" in the margin, but not that indicating the cursor. The error failed to appear in subsequent mouse overs.
Addendum: I have another extension installed called Overview Margin. I think it might show the right side margin for the editor. The error occured when moving the mouse over it, while your Regex margin was not shown and the project was just loaded. Maybe that helps narrow it down.
That's great that you update your addin! I really love it :)
About back colour - you can use one of VS colours (something like CommandBarGradientMiddle), so anyone can change it using Theme Editor. Anyway, default system colour looks pretty nice too.
Also you can add few standard tricks from VS Find dialog:
- You can copy selected text in code editor to "Find Next textbox" when user presses alt r;
- If found word was out of text view, then you may scroll view, so this word will be centered in the view (for now it is placed in bottom or at the top of view). As I know for this feature may be used EnsureSpanVisible function.
Thanks again for great addin :)
P.S. I'm also using Overview Margin extension, but never experience any problems with both of this extensions.
I'm sorry that you ran into that exception. I also have the overview margin installed so I'll play around with your scenario to try to repro.
Great suggestion about the autofilling of Find Next textbox and scrolling the result to view in the middle. I'll investigate.
Will keep both of you posted!
I have fixed the exception, and updated the scrolling behavior so that we scroll the match to the middle of the screen if it's not currently visible. Note that IEditorOperations.SelectAndMovecCaret(...) is great for this, simply pass in EnsureSpanVisibleOptions.ShowStart. :)
CorwinAlex, I thought more about autopopulating, and decided to not do that for now. My workflow is that I bring up the regex margin and type in an expression, hit escape to hide the margin, navigate around the matches, then I want to bring the regex margin again to update my expression, and I don't want to lose what expression I had previously entered. Great idea though! This did make me think about doing a MRU list for the Find Next/Replace With textbox :)