Replace new line with comma in Sublime Text Editor

If you have a file or a string that you want to replace every new line with a comma follow the below steps,

  1. Open the file in Sublime Text Editor,

    Example file with multiple lines

    This is my Line 1
    This is my Line 2
    This is my Line 3
    This is my Line 4
    This is my Line 5
  2. Now press Control + H (or Command + H on macOS),
  3. Make sure you select .* button to enable RegEx,
  4. Now in Find: add \n (if windows encoding file) \r\n (if mac encoding)
  5. Add Replace: as "," (without the quotes).
  6. Click on REPLACE ALL! Thats it!


This is my Line 1,This is my Line 2,This is my Line 3,This is my Line 4,This is my Line 5

⛏️ Note: If you want to a space after each comma, just add a space after the comma ", " in Replace.

Let's me give you a gif demo to make it easy to follow,

How to replace new line with comma in Sublime Text
How to replace new line with comma in Sublime Text

Topics Coverage:

🎉 We are celebrating the 10th years of Code2care! Thank you for all your support!

We strongly support Gender Equality & Diversity.

Follow Us: GitHub | Facebook | Twitter | Instagram