• Login
Community
  • Login

Cannot paste into replace field

Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
15 Posts 4 Posters 1.7k 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 Dec 9, 2020, 9:22 PM

    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

    A 1 Reply Last reply Dec 9, 2020, 9:34 PM Reply Quote 0
    • A
      Alan Kilborn @Tuomas J. Alaterä
      last edited by Alan Kilborn Dec 9, 2020, 9:35 PM Dec 9, 2020, 9:34 PM

      @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
      • A
        Alan Kilborn
        last edited by Alan Kilborn Dec 9, 2020, 9:39 PM Dec 9, 2020, 9:38 PM

        @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 Dec 9, 2020, 9:55 PM

          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!

          A 1 Reply Last reply Dec 9, 2020, 9:56 PM Reply Quote 1
          • A
            Alan Kilborn @Tuomas J. Alaterä
            last edited by Dec 9, 2020, 9:56 PM

            @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 Dec 9, 2020, 10:03 PM Reply Quote 0
            • T
              Tuomas J. Alaterä @Alan Kilborn
              last edited by Dec 9, 2020, 10:03 PM

              @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. ;)

              A 1 Reply Last reply Dec 9, 2020, 10:06 PM Reply Quote 0
              • A
                Alan Kilborn @Tuomas J. Alaterä
                last edited by Dec 9, 2020, 10:06 PM

                @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 Dec 9, 2020, 10:17 PM Reply Quote 3
                • T
                  Tuomas J. Alaterä @Alan Kilborn
                  last edited by Dec 9, 2020, 10:17 PM

                  @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
                  • G
                    guy038
                    last edited by guy038 Dec 10, 2020, 12:16 AM Dec 10, 2020, 12:08 AM

                    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

                    A R 2 Replies Last reply Dec 10, 2020, 12:17 AM Reply Quote 3
                    • A
                      Alan Kilborn @guy038
                      last edited by Alan Kilborn Dec 10, 2020, 12:18 AM Dec 10, 2020, 12:17 AM

                      @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
                      • G
                        guy038
                        last edited by guy038 Dec 10, 2020, 12:52 AM Dec 10, 2020, 12:48 AM

                        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

                        A 1 Reply Last reply Dec 10, 2020, 1:56 AM Reply Quote 2
                        • A
                          Alan Kilborn @guy038
                          last edited by Dec 10, 2020, 1:56 AM

                          @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
                          • A
                            Alan Kilborn
                            last edited by Dec 10, 2020, 1:34 PM

                            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
                            • R
                              Richard Kopeikin @guy038
                              last edited by Jul 26, 2023, 1:47 PM

                              @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

                              A 1 Reply Last reply Jul 26, 2023, 2:01 PM Reply Quote 0
                              • A
                                Alan Kilborn @Richard Kopeikin
                                last edited by Alan Kilborn Jul 26, 2023, 2:02 PM Jul 26, 2023, 2:01 PM

                                @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