Cannot paste into replace field



  • 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



  • @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.



  • @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.



  • 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!



  • @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. :-)



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



  • @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



  • @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!



  • 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



  • @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!



  • 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



  • @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.



  • 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.


Log in to reply