Search and replace over multiple lines?

Search and replace over multiple lines?

2
NewbieNewbie
2

    Feb 02, 2005#1

    Hi,

    UltraEdit is a great program been using it to develop in for about six years!

    It would be great to be able to search and replace over multiple lines.
    I can search over multiple lines, but it won't allow me to paste in my replacement if it is more than one line.

    Cheers,
    Chris.

    46
    Basic UserBasic User
    46

      Feb 02, 2005#2

      I perhaps not really understood the question but, did you try the ^p in the replace string where you want line break?

      Regards,
      Alain

      2
      NewbieNewbie
      2

        Feb 02, 2005#3

        I will try that. But if you put several lines in the clipboard and paste them into the replace box it will only show the top line.
        It would be nice if it would let you paste all the lines in.

        Cheers,
        Chrisl

        1
        NewbieNewbie
        1

          Feb 23, 2005#4

          Yes! This is the single feature I MOST want UltraEdit to have.

          Please, please if anyone's reading.. please implement this. I'll have your children if you do.

          58
          Advanced UserAdvanced User
          58

            Feb 23, 2005#5

            I know that pasting multiple lines won't work. But there is a simple workaround. Simply have those multiple lines you want to search for selected when pulling up the Find or Replace dialog. Works for me.

            Manni

            1
            NewbieNewbie
            1

              Mar 09, 2005#6

              ctoybee wrote:
              I will try that. But if you put several lines in the clipboard and paste them into the replace box it will only show the top line.
              It would be nice if it would let you paste all the lines in.
              This phenomena happens to me too. I have the impression that it becomes more annoying and appears more often after the upgrade to Windows XP SP2.

              So far I've found out that under circumstances it possible is to paste multiple lines into the replace dialog box.
              This depends on the sort of "end of line" character(s). (cr/lf; /n; or in hex:A0 D0 or something like that etc.) By some of the "end of line" character it is impossible to paste more then one line. Those weird EOL characters can be found mostly in a file not created with Ultra Edit.

              What I do in such a case is to get rid of the EOL characters (backspace) and replace them with an ordinary "enter" and then I use copy/paste into the replace dialog box.

              Of course I'm not happy with this situation.
              Is my impression right that it just appears after an upgrade to Windows XP SP2?

              Normally I use UltraEdit 9.0 on Windows XP SP2. But to check if this behavior is version dependent I've download a 10.20+ version to try out. No difference in version concerning this matter.

              8
              NewbieNewbie
              8

                Mar 25, 2005#7

                I'm not sure if you're using UE11 or not, but in UltraEdit-32, there's a box you can check in the "Replace Text" area to replace text only in the selected area - works like a charm.

                1
                NewbieNewbie
                1

                  Aug 05, 2005#8

                  I got a similar request, find and replace over multiple files, over multiple lines. Apparently there is some very unuser-friendly way of doing things, with the copy and paste buffer.

                  However, I asked for the following feature request:

                  Code: Select all

                  Add support for templates, in the search and replace window, if Regular Expressions are not selected.
                  I would like to add ^1, ^2, ^3 etc. to match the template 1,2,3 etc. in the search & replace window (also over multiple files). See Advanced/Individual Templates for templates in UltraEdit.

                  Let cross the fingers the programmers add this features. Shouldn't be too difficult, and makes lots of people happy !
                  Erwin

                  3

                    Sep 08, 2005#9

                    I sent an email to IDM support and got a reply right away from Troy:
                    Troy wrote:REPLACING BLOCKS OF CODE:
                    When using Replace in Files in this manner you have to be very sure that what you're searching for in the Find string is unique text so you aren't accidentally replacing something that you didn't intend to.

                    Having said that, all you need to do is copy all the text you want to use as your Replace string to the clipboard (select and hit Ctrl+C) and then select the text you want to search for and invoke the Replace in Files function.

                    The selected text will populate the Find field and you can use "^c" (no quotes) to refer to the content of the clipboard for the Replace With field.
                    Since this is such a common issue, I also requested that they add this hack to the Help document.

                    I heard from Andy at IDM about that issue:

                    Thanks for your response.  I will ask the developers to consider
                    adding a tip in the Help regarding the replace technique.

                    Thanks, Andy

                    6,604548
                    Grand MasterGrand Master
                    6,604548

                      Sep 09, 2005#10

                      Also possible is to select the block in one file. Then run this normal (not regular expression!) Replace All only on the Selected Text:

                      Find What: ^p
                      Replace With: ^^p

                      This converts all line endings of the selected block to characters ^p.

                      Copy the still selected text now to windows clipboard and use the undo function to undo the line ending replace in the current file. Now open the "Replace In Files" dialog and paste the block search string into the Find and also Replace field and modify it in the replace field to whatever you want.

                      Of course, this can method can only be used for normal search and replaces in files, not for regular expression replaces. It's possible to convert the normal find string to a regular expression string before executing the "Replace In Files", but if the numbers of lines are not equal in all files, it will become tricky.

                      Note: ^p is for files with CRLF (DOS). If you want run a Replace In Files with HTML files which are stored in Unix format use in the replace field ^^n for LF only (Unix) instead of ^^p.
                      Best regards from an UC/UE/UES for Windows user from Austria

                      1
                      NewbieNewbie
                      1

                        Nov 28, 2005#11

                        Is there a limit to the length of text that can be searched and replaced? I was running into this same problem as discussed below but then did find that UE was smart enough to automatically copy the multirow text into the find combo... however, when I had selected strings that were substantially long... like 500 characters, this technique did not seem to work.

                        6,604548
                        Grand MasterGrand Master
                        6,604548

                          Nov 29, 2005#12

                          For normal search the limit is exactly 1000 bytes. So I guess, it will be also for replace in files. The limit for the replace string is also exactly 1000 bytes.

                          You can break these limits by using ^s (selected text) and ^c (clipboard content).

                          First select and copy the replace "string" into the clipboard. Then select the text which should be searched and replaced. Open the replace dialog and enter in the find field ^s and in the replace field ^c. But you cannot use ^s and ^c (normally) for a regular expression replace.

                          Attention: Be careful with ^c and ^s when used with Replace In Files when the HTML files are saved in Unix format. If the opened HTML file is opened with conversion to DOS, every line is terminated with CRLF and so the clipboard content and the selected text used in Replace In Files will also have CRLF at end of every line which then will not work or in worst case produce a HTML file with mixed line endings (parts with Unix, parts with DOS). In this case you have to temporarily disable the Automatically convert to DOS format configuration option, open one HTML file, copy the search block to clipboard (now only with LF) and select the replace block or vice versa search block is selected and replace block is in clipboard. After Replace In Files close the HTML file and reenable the option Automatically convert to DOS format.
                          Best regards from an UC/UE/UES for Windows user from Austria

                          1
                          NewbieNewbie
                          1

                            Nov 29, 2005#13

                            Multiple lines isn't so bad but it can be tricky!

                            The #1 problem is Unix vs Windows. If your files are Windows, treat carriage returns as ^p, for Unix they are ^n.

                            I've been replacing some old MUD code and have done quite a bit of work with replace in files.

                            Example:
                            /* My code */
                            long_desc = "testing\n"
                            "one\n"
                            "two\n";

                            Replace exp: ^(long_desc = ^)^("*^n*^n*"^)^(;^)
                            Replace with: set_long(^2);

                            This is tricky, because when you're testing before the big replace using regular replace, you have to use ^p's instead of ^n's! :) Not fun!

                            4
                            NewbieNewbie
                            4

                              Sep 29, 2006#14

                              Hello!

                              I have a website that I am now editing in UltraEdit. It has about 200 files in a directory tree. There are certain blocks of text that are common to each page. The common blocks are the Navigation Bar text, The Right Column Text, and the Footer Text.

                              I want to add something to the Footer Text. To do this, I would like to Find and Replace a section of code that is around 250 characters long with one that is around 350 characters long. I want to do this in all 200 files.

                              I am a new user just learning the program. I can write in HTML, but am not a programmer, but am willing to learn what I need to.

                              I first tried to simply copy and paste the lines of code into the [Search - Replace In Files] but it would not accept lines that long. It simply cut off most of what I pasted into the Find Replace boxes.

                              I then discovered that the ^c would allow me to copy the search portion of my text, and have UltraEdit Find it, but it still did not solve the Paste portion.

                              I also have searched this forum, but I was unable to find the solution.

                              Help will be greatly appreciated.
                              dk

                              6,604548
                              Grand MasterGrand Master
                              6,604548

                                Sep 30, 2006#15

                                Hello Purposeinc!

                                The solution for your problem is answered in my (Mofi) 2 posts above.

                                Because of your question I edited my 2 posts with important special notes for usage of Replace In Files with HTML files which are often in Unix format while a HTML file is (or better should be) always opened with temporary auto-conversion to DOS.
                                Best regards from an UC/UE/UES for Windows user from Austria

                                Read more posts (12 remaining)