Separate a Single Line into Several New Lines with Atom
The Atom text editor is truly a powerful tool. I recently had the need to separate a long line, separated by commas, into several new lines. For example, I was given a line like this:
cucumber, walnuts, meatballs, broccoli, eggplant, tamarind, fried chicken
and I needed to turn this single line into seven new lines.
cucumber
walnuts
meatballs
broccoli
eggplant
tamarind
fried chicken
For a small sample set, I could hit enter seven times, but what if you had 100 lines? Or 200 lines? The Atom text editor has a tool that can save you some time. Using the Find in Buffer tool, you can turn on the Regex option and find all characters that have follow “, ” and replace it with “\n”. The Regex option is located on the right hand side and is noted by the .* characters. Here’s a screenshot of what the find tool looks like with the options set:
Once entered, you can click replace all to remove the comma+space combination and replace it with a new line. This shortcut is helpful for any list – a list of states, a list of counties, a long list of miscellaneous items.