replace function



  • thanks claudia
    not easy but yes works
    it will be great if some one could make a plugin to simplify this
    or perhaps a next update of notepad++



  • @kat75, @Claudia-Frank :

    Does this really work when there are multiple lines in the replace text? It doesn’t work for me; I find the behavior consistent with the discussion in this thread (https://notepad-plus-plus.org/community/topic/12973/multiple-line-replacing-doesn-t-work) where it doesn’t work for the OP and @guy038 concurs…



  • @Scott-Sumner

    yes, tested on 7.3.3 and 7.4 (both 32 bit).
    Scott, I do not fake screenshots :-D

    Cheers
    Claudia



  • @Claudia-Frank

    Ah, okay, this is good to know. You are way-more bleeding edge than I want to be, with the Notepad++ version you’re using. I try to not be too far behind, but reading about problems here (esp. recent 7.4 problems, for ex.) gives me strong hints about which version to (not) use.

    I don’t see anywhere in recent “new features and bug-fixes” list where it mentions a change in this area. Nice.

    It is good that it works as you describe now; takes care of the need of the OP in the thread I referenced earlier. And it is not overly burdensome to do (IMO), contrary to what @kat75 was saying.



  • @Scott-Sumner

    a nice improvement would be, if you have a active selection and you click into
    find what and/or replace with fields, it automatically replaces the previous used ones.

    So this would simplify it to,

    Select the text block
    open replace dialog (find what: is filled automatically)
    select the text block you want to be used as replacement
    click into replace with field, which than is updated with the current selected text.

    Cheers
    Claudia


  • Banned

    @Claudia Frank:

    I admire your Notepad++ savvy. You might be a bit bossy (even condescending) at times, but that’s OK with me. After Donald Trump in the White House, just about everybody is a saint(ess)!

    The OP wanted a search/replace (in opened files or on disk) as the ‘Replace Text” freebie by Ecobyte. I presented that very productive and convenient feature here:

    https://notepad-plus-plus.org/community/topic/13808/search-replace-of-multiline-text-blocs

    I thought Notepad++ would do that in the ‘Extended (\n, r, …)’ search option. It doesn’t — and we can only hope the feature will be added in a future release.

    I tried your procedure. The ‘Find what’ worked, although I didn’t see any special character between the copied lines.

    Unluckily, the ‘Replace with’ box only copied the first line of text. See screenshot. I use 32-bit Notepad++ v7.3.3.

    Extended Search/Replace in Notepad++

    Hope you have influence on the highly skilled creator of Notepad++.

    Ion Saliu
    “A good man is an axiomatic man; an axiomatic man is a happy man. Be axiomatic!”



  • @Ion-Saliu

    Yea, I just tried the same test with 7.4 and it didn’t do the multiline thing in the replace-with box, so now I’m starting to think that @Claudia-Frank IS faking screenshots.

    :-D



  • @Ion-Saliu

    You might be a bit bossy (even condescending) at times, but that’s OK with me. After Donald Trump in the White House, just about everybody is a saint(ess)!

    Might I ask what you are referring to?

    Cheers
    Claudia



  • @Claudia-Frank

    You might be a bit bossy (even condescending) at times…

    Might I ask what you are referring to?

    I don’t read every posting, but I cannot imagine there is even one where you were even in the neighborhood of bossy or condescending.

    I’ve seen you reply admirably to posts that I wanted to respond to with some response along the lines of, “Come back when you have the faintest idea what you are doing”. The best I could do was resist the urge, but you put me to shame with your thoughtful, helpful answers. Keep up the tremendously good work!



  • @Scott-Sumner

    took some time to create the animated gif.

    Cheers
    Claudia


  • Banned

    @Claudia Frank:

    There is something strange about you, axiomatico. Methinks you cook the books. Or, perhaps your version of Notepad++ is special and not available to programmers like me.

    I did it again. Once again, the procedure didn’t work in my Notepad++ neck-of-the-woods. The replace box only copies the first line in the bloc. I used the ‘Edit’ menu and also the contextual menu (right-click). Look again at the screenshot:

    Extended Search/Replace in Notepad++ClaudiaCheat

    So, what you did: Cook the books. You created just one paragraph in a narrow screen with ‘Word-wrap on’. Why don’t you do on a page I know? Download this page from my website, open page source, copy-and-paste the content to a new Notepad++ file. Apply your procedure and show us a real screenshot.

    The page is a little more complicated as it has ‘pre’ sections that show different fonts.

    Statistical Page Pick-3 Lottery in Notepad++

    If not, you have a serious behavioral problem (@Scott Sumner nods approvingly). Notepad++ is not served by fabricating things.

    Ion Saliu
    “A good man is an axiomatic man; an axiomatic man is a happy man. Be axiomatic!”



  • @Ion-Saliu

    Could it be that it is related to Unix? I’m running npp on ubuntu.
    Would you give it a try to convert eols to unix and redo the test?

    What about my question? Do you wanna answer it or do you prefer to keep insulting me?

    Cheers
    Claudia


  • Banned

    Axiomatic Ones:

    Maybe there is another scenario in play here. Maybe this multiline replace function WAS present in a previous version of Notepad++. Obviously, I didn’t check every version regarding this replace function. Was it really present in a previous versions? Was the function dropped consciously (e.g. for copyright reasons) or inadvertently?

    Methinks it might be an overlooked property setting. Visual Basic has a property setting for the textbox: ‘Multiline = True’. Look at that under the property sheet of ‘Replace textbox’.

    Now, this hyper active Claudia Frank maybe works with a previous version of Notepad++ that featured the multiline replace. She should have been honest and tell us what version of Notepad she used. She just posted that actually she works with a Linux version of Notepad++. Scott Sumner and I disclosed the versions we are using.

    I run 32-bit Notepad++ on 64-bit Windows 10.

    Now, I put the blame squarely on the author of this excellent editor. This replace thingy has been debated a lot — I mean, a lot. There are several threads with hundreds of posts in this very community. Why does the author hide in silence? He knows better than anybody else if the feature we are debating here IS PRESENT OR NOT IN NOTEPAD++. Just a few paragraphs will do. Posts by Claudia Frank won’t do. She is disingenuous. She cooks the books, even by Photoshopping…

    Ion Saliu
    “A good man is an axiomatic man; an axiomatic man is a happy man. Be axiomatic!”



  • @Claudia-Frank , @Ion-Saliu

    Claudia, why in the animated GIF when you right-click on the replace-with box does the popup menu appear so much different than mine? I can’t quite read yours in the graphic (too small, too fast) but it is definitely “different” and I don’t know why that would be…some side effect of running under Wine?

    Anyway, Claudia, your last hint has solved the mystery of why this works for you and not me or Ion…Linux line-endings!! If I try to duplicate your procedure on text with LF only as the line-ending it works for me as it does for you (allows multiple lines in the replace-with box)…same test with CR+LF as line-ending fails (only puts first line of multiline select block in the replace-with box) as previously reported.

    I thought it was pretty clear that my hint about “fakery” (“maybe Claudia IS faking screenshots”) was all in jest…that’s why I followed that with a :-D… If that was misinterpreted then I cannot apologize enough. However, if Ion is also jesting, he has taken it to a totally different level and personally I don’t find that warranted or acceptable. As Jim stated earlier, Claudia’s inputs to this community are invaluable, and when she disappears for a period of time (as she tends to do sometimes) she is sorely missed here. She always signs with “Cheers” but the real CHEERS go to Claudia!

    And Ion, please don’t “nod my head approvingly” on my behalf–I can do that for myself if need be. :)


  • Banned

    @Scott Sumner

    Axiomatic One:

    Claudia Frank does “fake the stake”. You wasn’t jesting about it. Look at her reply in another thread. She FAKES on-the-fly font changing in Notepad++, much like in Microsoft Word. That is NOT a real feature in Notepad++. She Photoshopped the screenshot:

    https://notepad-plus-plus.org/community/topic/13829/improments-about-notepad-font

    As for the animated image, methinks she also “faked the stake” or “cooked the books”. There was a bloc of empty space in a Notepad++ file. One can type text and presses the down arrow to create the impression of multiple lines. They ain’t real lines, but part of a single paragraph.

    I did the following experiment in the same HTML file I used in my first screenshot. I selected a paragraph that consists of several lines. But those are NOT real lines. The appearance of multiple lines is created by word-wrap on.

    Search/Replace in Notepad++SingleWrappedLine

    What many posters in this community want is REPLACE OF MULTIPLE REAL LINES, NOT SINGLE LONG LINES. That’s why we are in this thread and several other threads on the same topic.

    Again, I put the blame squarely on the author of this excellent editor. This replace thingy has been debated a lot — I mean, a lot. There are several threads with hundreds of posts in this very community. Why does the author hide in silence? He knows better than anybody else if the feature we are debating here IS PRESENT OR NOT IN NOTEPAD++. Just a few paragraphs will do. Posts by Claudia Frank won’t do. She is disingenuous. She cooks the books, even by Photoshopping. For what? For NO reason, because she has a problem, she is not a reasonable person. It makes people waste their time reading her posts, taking her procedures at face value, when, in fact, she fakes the stakes…

    Ion Saliu
    “A good man is an axiomatic man; an axiomatic man is a happy man. Be axiomatic!”



  • @Scott-Sumner

    Hi Scott,

    Claudia, why in the animated GIF when you right-click on the replace-with box does the popup menu appear so much different than mine?

    actually I don’t know - I once played with the different ui languages and now I do have
    a German context menu but only in dialogs (it looks like). The context menu of the editor
    is still English.

    I thought it was pretty clear that my hint about “fakery” … was all in jest

    To me it was :-)

    However, if Ion is also jesting…

    I don’t think so, but not worth to worry about.

    Not sure if I find the time to check why the two fields in the dialog
    are handled differently but … let’s see.

    Cheers
    Claudia



  • @Claudia-Frank said:

    why the two fields in the dialog are handled differently

    I guess there are FOUR real differences:

    • Find-what box with Windows line endings between lines
    • Find-what box with Linux line endings between lines
    • Replace-with box with Windows line endings between lines <-- the true troublesome one
    • Replace-with box with Linux line endings between lines


  • it was not easy for me to succeed too, sometimes i succeed other time i dont succeed, perhaps its because of me i dont know
    but notepad++ is a great tool hope it could be a next developement to make this more easy



  • Hello, @kat75, @scott-sumner, @claudia-frank, @jim-dailey, @ion-Saliu and All,

    First of all, I totally agree to what Scott and Jim said : the Claudia’s contribution to our forum, is really awesome, in a huge lot of domains ! Congratulations for your global insight on technical problems and your inexhaustible availability to all of us !!

    And…, @ion-Saliu, no doubt : you certainly have an ego much greater than Donald Trump’s one ! You should have followed that forum, for some time, to realize that you’re just saying stupidities and discourteous things about Claudia. And, when you say :

    It makes people waste their time reading her posts, taking her procedures at face value, when, in fact, she fakes the stakes…

    I simply think, on the contrary, that we’re just wasting our time reading yours ! Indeed, change your attitude ! If not, as one of the moderators of that site, I could take the responsibility to delete some of your posts…

    Well, now, let’s go back to an interesting topic : the last Claudia’s discovery !!


    Oh ! A THOUSAND thanks, Claudia, for finding out the solution to paste multi-lines in the Replace dialog :-)))

    I did some tests, and AFAIK, it happens that :

    • Any range of lines, copied, in the Find box, whatever the End of Line character(s) of each line, of that block, will be searched, exactly, with the same line endings. That is to say, for instance, that the text, below :

    123 CR LF
    456 LF
    789 CR

    copied in the Find what: box, will not find this other multi-lines text below :

    123 CR
    456 CR LF
    789 LF

    • Any range of lines, copied, in the Replace with: box, with the Unix end of line LF, exclusively, ( \n ) will replace all the searched text, either mono or multi lines !

    • It does not depend, too, on the Search mode ( Normal, Extended, or Regular expression ) However, to avoid unpredictable results, it seems sensible to use, preferably, the Normal search mode.

    • Moreover, beware to always leave the Match whole word only option UNCHECKED, if Normal or Extended mode is set !

    • IMPORTANT : The Find what: and Replace with: boxes may contain a maximum of 2046 characters. So, once a block of lines selected, either for the Search or the Replace part, just have a glance, at the status bar, to know the size of the selection !


    Practically, in Windows files :

    UPDATE : Just forget the procedure, below, and jump to my other post, where I propose a more simple method, indeed !

    https://notepad-plus-plus.org/community/topic/13823/replace-function/29


    • Firstly, change your Replace block of Windows lines into a block of Unix lines :

      • Do a normal selection of your Replace block of lines ( Remember : not more than 2046 characters ! )

      • Open the Replace dialog ( Ctrl + H )

      • Type \R in the Find what: box

      • Type \n, in the Replace with: box

      • Check the In selection option ( IMPORTANT )

      • Select the Regular expression search mode ( IMPORTANT )

      • Click on the Replace All button

      • Close the Replace dialog

    • Do a normal selection of your Search block of Windows lines ( Remember : not more than 2046 characters ! )

    • Open, again, the Replace dialog ( Ctrl + H )

    => The searched block is automatically inserted, in the Find what: box

    • Select and copy your block of Unix lines, which will replace the searched text ( CTRL + C )

    • Paste this block, in the Replace with: box ( Ctrl + V )

    • Choose, preferably, the Normal search mode

    • Uncheck the Match whole word only option ( IMPORTANT )

    • Check/Uncheck the Match case ans Wrap around options, as you want

    • Click, once or several times, on the Replace button or once, only, on the Replace All button

    => The Replace blocks should have replaced the Search blocks :-))

    To end with, we have to change all the unique Unix LF characters, \n, in Replace blocks, by the classical Windows End of Line characters ( \r\n )

    • Open, again, the Replace dialog ( Ctrl + H )

    • Type the regex (?<!\r)\n|\r(?!\n), in the Find what: box

    • Type the regex \r\n, in the Replace with: box

    • Click on the Wrap around option

    • Select the Regular expression search mode

    • Click on the Replace All button

    Et voilà !!

    Notes

    • In this last S/R, we look for, either :

      • A LF character ( \n ), not preceded by a CR character

      • A CR characte ( \r ), not followed by a LF character

    • And, in replacement, we change this unique End of Line character, by the two Windows line break characters ( \r\n )

    Best Regards,

    guy038



  • @guy038

    Hi Guy,

    as usual great info.
    I didn’t thought I get the chance, but now comes my time to shorten your eol conversion.
    Goto Edit->EOL Conversion-> and choose the appropriate one ;-)

    Cheers
    Claudia


Log in to reply