Community
    • Login

    Cannot paste into replace field

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    15 Posts 4 Posters 1.6k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • T
      Tuomas J. Alaterä
      last edited by

      Baffled here. Suddenly I cannot paste from text to search and replace. Please see the screen cap. If I select

      ipsum</p>
      

      and would like to replace them with

      <p> 	 <br />
      Lorem ipsum</p>
      

      only the characters in from the first row appear to replace with field. Why doesn’t it copy past the first line? Just a few days ago I was able to copy and paste multiple lines without an issue and I don’t recall changing anything. Pasting to anywhere else gives all the lines. Any help appreciated.

      notepadproblem.png

      Alan KilbornA 1 Reply Last reply Reply Quote 0
      • Alan KilbornA
        Alan Kilborn @Tuomas J. Alaterä
        last edited by Alan Kilborn

        @Tuomas-J-Alaterä

        Nope, you are remembering wrongly.
        Notepad++ has never supported paste of multiple lines into the Replace with field.

        The way to do it is with regular expressions and putting desired_line_1\r\ndesired_line_2\r\n in the Replace with box.

        1 Reply Last reply Reply Quote 2
        • Alan KilbornA
          Alan Kilborn
          last edited by Alan Kilborn

          @Tuomas-J-Alaterä said in Cannot paste into replace field:

          Pasting to anywhere else gives all the lines

          To address this part:

          You cannot paste multiple lines into the Find what field, either.
          What you can do, and probably what you’ve done in the past, is to select multiple lines, and then press Ctrl+H (to start a replacement action), and THEN your multiple-line data is put there by the Notepad++ code logic.

          Traditional paste, e.g. Ctrl+v, will not paste such data into Find what or Replace with.

          1 Reply Last reply Reply Quote 1
          • T
            Tuomas J. Alaterä
            last edited by

            Facepalm moment… Of course. I use Ctrl+H all the time and was finding large chucks of text/markup using Find in files but replacing with regular expressions. I suppose the exact same functionalities are in place for Find in files too? (Which is an extremely handy tool, if someone hasn’t noticed yet.)

            Thanks for the quick reply and for saving me from looking for a solution to a problem that does not exist!

            Alan KilbornA 1 Reply Last reply Reply Quote 1
            • Alan KilbornA
              Alan Kilborn @Tuomas J. Alaterä
              last edited by

              @Tuomas-J-Alaterä said in Cannot paste into replace field:

              exact same functionalities are in place for Find in files too?

              Yes, the actual edit controls I mentioned are shared on the tabs of the Find family, so they all have those limitations.

              Usually at this point in time, people rant and rave and complain that these controls don’t better support multiline – there really isn’t any reason that they shouldn’t. :-)

              T 1 Reply Last reply Reply Quote 0
              • T
                Tuomas J. Alaterä @Alan Kilborn
                last edited by

                @Alan-Kilborn said in Cannot paste into replace field:

                Usually at this point in time, people rant and rave and complain that these controls don’t better support multiline – there really isn’t any reason that they shouldn’t. :-)

                Which is why I have another editor to do that if/when I’m too lazy with regex. ;)

                Alan KilbornA 1 Reply Last reply Reply Quote 0
                • Alan KilbornA
                  Alan Kilborn @Tuomas J. Alaterä
                  last edited by

                  @Tuomas-J-Alaterä said in Cannot paste into replace field:

                  why I have another editor to do that

                  The ToolBucket plugin can do it…maybe keep you in Notepad++? :-)

                  d644c5f4-24f9-4182-a554-2fe995e26178-image.png

                  T 1 Reply Last reply Reply Quote 3
                  • T
                    Tuomas J. Alaterä @Alan Kilborn
                    last edited by

                    @Alan-Kilborn said in Cannot paste into replace field:

                    The ToolBucket plugin can do it…maybe keep you in Notepad++? :-)

                    Checking that out now, thanks. Looks perfect for the job. Sounds like I rather stay than leave!

                    1 Reply Last reply Reply Quote 2
                    • guy038G
                      guy038
                      last edited by guy038

                      Hello, @tuomas-j-alaterä, @alan-kilborn and All,

                      Ah… I’m really pleased as I’ve found out an interesting work-around to perform multiple-lines search and the replacement with multiple-lines text, too ;-))

                      I did some tests and, after a while I said to myself : what about a Mac line-break ( \r only ) or an Unix line-break ( \n only ) between two lines and… Bingo it works nicely with Unix files !!


                      Here are the simple steps of this work-around, if you are using NON-Unix files :

                      • First perform the Edit > EOL Conversion > Unix (LF) menu option

                      • Do a normal selection of any multi-lines block of text

                      • Copy this block of lines in the clipboard ( Ctrl + C )

                      • Open the Replace dialog ( Ctrl + H )

                        • Select the Normal search mode

                        • Wipe out the two Find what: and Replace with: zones

                        • Select the Find what: zone

                        • Paste your searched block of lines ( Ctrl + V )

                      • Put the focus, again, on your text

                      • Do a normal selection of any multi-lines block of text, which will replace the searched block

                      • Copy, again, this block of lines in the clipboard ( Ctrl + C )

                      • Return to the Replace dialog ( Ctrl + H )

                        • Select the Replace with: zone

                        • Paste your replacement block of lines ( Ctrl + V )

                        • Click on the Replace or Replace All button

                      => You get your expected replacement !

                      • Finally, perform the Edit > EOL Conversion > Windows (CR LF) or Edit > EOL Conversion > Macintosh (CR) menu option

                      Done !!!


                      I’m going to do some additional tests with the Extended search mode !

                      Best Regards,

                      guy038

                      Alan KilbornA Richard KopeikinR 2 Replies Last reply Reply Quote 3
                      • Alan KilbornA
                        Alan Kilborn @guy038
                        last edited by Alan Kilborn

                        @guy038 :

                        Very interesting.

                        To make it a faster process, instead of:

                        … perform the Edit > EOL Conversion > Unix (LF) menu option

                        … perform the Edit > EOL Conversion > Windows (CR LF) or Edit > EOL Conversion > Macintosh (CR) menu option

                        Just double-click the line-ending area in the N++ main window status bar, and you’ll get a popup menu for the conversions that are possible. Very fast to do the operations this way instead of weaving through the Edit menu choices.

                        Note that I “struck thru” the Mac conversion operation above – nobody seriously uses that these days!

                        1 Reply Last reply Reply Quote 0
                        • guy038G
                          guy038
                          last edited by guy038

                          Hi, @tuomas-j-alaterä, @alan-kilborn and All,

                          Taking into account @Alan-kilborn’s sound advice, and, after additional tests, the different steps of this work-around can be simplified as below :

                          • If you are using NON-Unix files, double-click on the line endings area, in the status bar, and select the Unix (LF) option

                          • Do a normal selection of any multi-lines block of text to search for

                          • Open the Replace dialog ( Ctrl + H )

                            • your search block is automatically placed in the Find what: zone

                            • Select the Normal search mode

                          • Put the focus, again, on your text

                          • Do a normal selection of any multi-lines block of text, which will replace the searched block of lines

                          • Copy this block of lines in the clipboard ( Ctrl + C )

                          • Return to the Replace dialog ( Ctrl + H )

                            • Select the Replace with: zone and wipe out any text

                            • Paste your replacement block of lines ( Ctrl + V )

                            • Click on the Replace or Replace All button

                          => You get your expected replacement !

                          • Finally, If you are using NON-Unix files, double-click, again, on the status bar and select the Windows (CR LF) option

                          You’re done !

                          Reminder : Both, search and replacement blocks of text must not exceed 2,040 characters, about !

                          Cheers,

                          guy038

                          Alan KilbornA 1 Reply Last reply Reply Quote 2
                          • Alan KilbornA
                            Alan Kilborn @guy038
                            last edited by

                            @guy038

                            It appears the thing that cannot be pasted into the two edit boxes is the carriage-return character, \r. The line-feed clearly has no problem to be pasted. I confirmed this by first switching to the dreaded Mac line-ending format, selecting multiple lines, and then attempting to paste those. Just like Windows line-ending formatted data, pasting Mac format is a “no go”.

                            Overall, this is a nice workaround, that isn’t too burdensome if you do a lot of this type of thing.

                            Maybe an idea is to convert the first conversion into a macro with two steps:

                            1. the line-ending conversion already mentioned, followed by
                            2. turning on visible line-endings (just as a reminder to do the conversion back)

                            and then the second conversion into the corresponding macro:

                            1. the other line-ending conversion already mentioned, followed by
                            2. turning off visible line-endings

                            This would keep you from forgetting to do the important conversion back to Windows format, because it would visually nag you that you haven’t done it yet (if you have to stare at that ugly black box with the LF in it.

                            These macros would then obviously work best if tied to a couple of keycombos.

                            1 Reply Last reply Reply Quote 2
                            • Alan KilbornA
                              Alan Kilborn
                              last edited by

                              I discovered a neat way of automating a bit of this.

                              If you use the EditorConfig plugin, and specify that your files are to have Windows line-endings, when you save, any other line-endings will be converted to that type.

                              Thus, if you use the technique above described by @guy038 , when you are done with your multiline manipulations, you don’t really have to set your file back to Windows line-endings, the EditorConfig plugin will do that for you.

                              1 Reply Last reply Reply Quote 2
                              • Richard KopeikinR
                                Richard Kopeikin @guy038
                                last edited by

                                @guy038 Thank you for this research and post. It saved my life.

                                Like the original poster, I thought that I was taking crazy pills. One day I could do a multiline find/replace using copy/paste into in the ‘find’ text field… then next day, BAM - nothing… But apparently that ‘BAM’ was me changing the default EOL to windows.

                                The multiline find/replace has been a super useful feature to me in the past. I tried using the toolbox option and wasn’t a big fan.

                                Much appreciation - XOXO

                                Alan KilbornA 1 Reply Last reply Reply Quote 0
                                • Alan KilbornA
                                  Alan Kilborn @Richard Kopeikin
                                  last edited by Alan Kilborn

                                  @Richard-Kopeikin

                                  Multiline search and replace was a big issue when this thread was originally created; now it isn’t such a large problem, because of the advent of the “swap” widget/control:

                                  74b18883-a9ac-4243-b548-5f9bbbcb6c3a-image.png

                                  It’s ALWAYS been possible to get multiline data into Find what if you select it and press Ctrl+h (or Ctrl+f), so if you need multiline data in Replace with you can select it (the replacement text) first, do Ctrl+h on it, then Copy from Find to Replace, then select your true Find what text and invoke Ctrl+h again.

                                  Kinda klunky, but it works.

                                  1 Reply Last reply Reply Quote 4
                                  • First post
                                    Last post
                                  The Community of users of the Notepad++ text editor.
                                  Powered by NodeBB | Contributors