Jump back to relevant section after prompted find/replace overshoots?



  • I’d be interested to hear if others have a solution to this “problem”:

    Say you are doing a prompted Replace operation on many matches that you are needing to change.
    Replace-and-find-next, replace-and-find-next, …
    Ooops, now you have found the first one BEYOND where you need to change (wow, now my caret is way far away in a totally unrelated section of the file).
    It would be nice to easily get back to the last one that you DID change with the replace operation so you can continue working – but how to painlessly achieve this?

    Sure, I could:

    • set a bookmark at each point N++ finds a match that I want to replace
    • block the whole range beforehand (and use the “in selection” option in the replace dialog)
    • mentally note the most recent line number where I Replaced, so that I could Goto the remembered line later

    …but these solutions are “burdensome”.

    Anybody have any other ideas that are maybe better for achieving this? Or am I alone in this bothering me?



  • @Alan-Kilborn

    if I understand correctly, than SHIFT+F3.

    Cheers
    Claudia



  • @Claudia-Frank

    I think the OP meant “replace”, not “find/replace”. because shift+f3 (find previous) works for the “find” case. But if you replace the find text with something else, doing a find-previous moves you to a different place, not where I think the OP is trying to “jump back to” (nearby to the last replacement made). Does this make sense?



  • UNDO (Ctrl-Z)
    Then REDO (CTRL-Y) the replace and the caret stays there.



  • Scott, yes, makes sense to me ;-)

    Cheers
    Claudia



  • @Claudia-Frank

    Regardless, I see @gstavi has a solution that I didn’t think of – I upvoted! :-)



  • @Scott-Sumner - me too :-D

    Cheers
    Claudia



  • I always use it to go back to the last place I edited after browsing around the file.



  • Okay, so this new thing (to me, at least) that I discovered is unrelated, but I think it may fall into the same category of handy tips just like the above-discussed UNDO+REDO thing…and it is sort of similar (do an action, then reverse it).

    Often I want to make a selection of whole lines with the mouse. More often than not, my code is indented quite a bit, making it uncertain that I am beginning my selection on the correct line when I click and drag on the line numbers in the margin (far away horizontally from the non-whitespace code). Sometimes I miss the correct line and have to start the selection over again. A minor frustration.

    I found that if I make a selection that includes a PARTIAL first line (convenient because I can start the selection AT my indented code), any number of full lines, and then a PARTIAL last line…then press Tab, then Shift+Tab (this part reminded me of the UNDO+REDO thing)…I get a selection of complete lines which includes the WHOLE first and last lines (remember that these started out as partial lines).

    Perhaps this technique will be useful to someone else…



  • Nice trick - indeed.

    Cheers
    Claudia



  • This (PARTIAL lines selection -> Tab -> Shift+Tab -> FULL lines selection) may not be such a great thing after all. After using it in an editing session, and sometimes much later, when doing an unrelated Delete Line operation (via the Delete Line shortcut key, with no selection active), some odd behavior occurs: the wrong line is deleted, I get TWO carets in odd places (I have Multi-Editing enabled)… If I narrow down further what is actually going on, I’ll post here again, but for now: beware of this tip!     : (


Log in to reply