In Notepad: select from the end of a line (clicking SHIFT + Right arrow key; you can't see it, but the newline character is now selected). Now, go to "Replace" and replace with nothing. The newline characters will all be replaced with nothing.
Open the find and replace dialog (press CTRL+H).
Then select Regular expression
in the 'Search Mode' section at the bottom.
In the Find what
field enter this: [\r\n]+
In the Replace with
: ,
There is a space after the comma.
This will also replace lines like
Apples
Apricots
Pear
Avocados
Bananas
Where there are empty lines.
If your lines have trailing blank spaces you should remove those first. The simplest way to achieve this is
EDIT -> Blank Operations -> Trim Trailing Space
OR
TextFX -> TextFX Edit -> Trim trailing spaces
Be sure to set the Search Mode to "Regular expression".
fapDaddy's answer using a macro pointed me in the right direction.
Here's precisely what worked for me.
Place the cursor after the first data item.
Click 'Macro > Start Recording' in the menu.
Type this sequence: Comma, Space, Delete, End.
Click 'Macro > Stop recording' in the menu.
Click 'Macro > Run a Macro Multiple Times...' in the menu.
Click 'Run until the end of file' and click 'Run'.
Remove any trailing characters.
Done!
Here's what worked for me with a similar list of strings in Notepad++ without any macros or anything else:
Click Edit -> Blank Operations -> EOL to space [All the items should now be in a single line separated by a 'space']
Select any 'space' and do a Replace All (by ',')
For Notepad++ 5.9
A regex match with \s+
worked for me:
Place your cursor after Apples, under Macro Tab, select Start Recording. Type the comma(,) character, space( ) character, and press End key, under Macro tab, select Stop Recording.
Ctrl+Shift+P for single playback.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With