Cannot paste into replace field
-
@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++? :-)
-
@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:
andReplace 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
orReplace All
button
-
=> You get your expected replacement !
- Finally, perform the
Edit > EOL Conversion > Windows (CR LF)
orEdit > 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 optionJust 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 theUnix (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
orReplace All
button
-
=> You get your expected replacement !
- Finally, If you are using
NON-Unix
files, double-click, again, on the status bar and select theWindows (CR LF)
option
You’re done !
Reminder : Both, search and replacement blocks of text must not exceed
2,040
characters, about !Cheers,
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:
- the line-ending conversion already mentioned, followed by
- turning on visible line-endings (just as a reminder to do the conversion back)
and then the second conversion into the corresponding macro:
- the other line-ending conversion already mentioned, followed by
- 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.
-
@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
-
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:
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.