6

Edit: While I refer to RegEx in my background, I'm not looking for you to fix my RegExp (thanks for trying though) - rather I want to know "how do I abort a search/replace in NotePad++".


Environment

I'm using latest version of NPP (v.5.9.6.2) on Windows 7 64 bit

Background (aka "The Problem")

Occasionally I use NPP to manipulate bits of text and more often than not I use regular expressions during that process. While it is no criticism of the product (how can it be?), Notepad++ allows me to do stupid things that don't behave as I intended. Case in point, I had a long list of values which I wanted to enclose in quote marks. I entered an accidentally aggressive expression and it caused an infinite loop.

The reason for the loop is immaterial and is not the point of my question - I've made this mistake more than once - i know it doesn't work, but I forget and months later will do the same thing again.

The problem is that when NotePad++ goes into this infinite loop, trying to complete the imposisble, I am effectively locked out of all of my unsaved documents and forced to kill the NPP process.

Question

I can't find anything documented in Help or in the NPP "forum" but does anyone know of a way for me to abort a search and replace, such as in the aforementioned scenario, thereby allowing me to back out of my mistake and more importantly, save all of my other documents?

Greg
  • 183
  • 8
  • Did you try to replace `\$` with `'` ? –  Aug 16 '12 at 11:17
  • Thanks for your reply and sorry if it's not entirely clear from my question, `$` was intended to match the end of the line and place a quote mark there (rather than, as you imply, looking for an explicit dollar sign and replacing that with quote). In any case though, it is the ability to abort the search that I am looking for really :) –  Aug 16 '12 at 11:30
  • 1
    Well, there is always end of string/file ahead, as you cannot go beyond that, so that might be an issue why you experience an infinite loop. I don't have NPP installed, but... how about replace `\b(?=$)` with `'` ? –  Aug 16 '12 at 11:50
  • In many RegEx flavors replacing `/^(.*?)$/` with `"'$1'"` works. Have you tried that? –  Aug 16 '12 at 11:55
  • I usually just do \r\n instead of $ and its working fine. – Burnzy Aug 16 '12 at 11:56
  • Guys - I appreciate you all sifting through the RegEx issue, but that really is just the background as to why I want to abort the search. I can get NPP to do what I want, but when I make a mistake I need to be able to recover from it and therein lies my question. (Question edited) –  Aug 16 '12 at 12:32
  • @Greg - When you execute infinity regex loop, you cannot stop it. If such "stop" feature would be implemented within regex execution, then regex itself would be very slow, as it would need to check user input during execution, so... you can't have it all... –  Aug 16 '12 at 12:42
  • I have voted to close this question, because I think it's off topic on StackOverflow and maybe more suitable on SuperUser. Regardless of this I think your question should rather be a feature request to the NPP author: make long running (regex) searches cancelable – splash Aug 16 '12 at 13:09
  • @splash Ok good point on SU versus SO, I guess. As a side note though, my point was that I didn't know *if* it were possible. If I knew for sure that it wasn't a supported feature, then it is indeed a clear feature request rather than a cry for help ;) –  Aug 16 '12 at 14:05
  • Re: close votes, I can see the argument for "Off topic" as per @splash, but don't understand whoever deemed this to be "Not constructive"...! Never mind though - I'm convinced that this is an unsupported feature of NPP and in any case I should have asked on SU :) –  Aug 16 '12 at 14:07

1 Answers1

1

Just by pure chance today I stumbled about the AnalysePlugin in NPP's Plugin Manager window and it says in its Latest update comments:

feature: please wait popup to allow user to cancel long lasting searches and a progress bar

This is not exactly what you are asking for (search AND replace), but it may be helpful for pure (long running) search.

splash
  • 251
  • 1
  • 5
  • Pending a test I'll mark this up answer. Great find @splash. – Greg Aug 21 '12 at 09:04
  • 1
    Actually, you're right it's not quite what I'm after (I got a bit too excited that it was just then!) but it is useful nonetheless. Also I've never really explored NPP plugins so you've just opened a whole new world of "wow look at that" for me ;) – Greg Aug 21 '12 at 09:10