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
Try Out Code2care Dev Tools:


Android Java Linux Microsoft Google Python macOS Notepad++ Microsoft Teams CSS PHP SharePoint Html Linux C Programs Bootstrap jQuery Sublime Android Studio Facebook Eclipse WhatsApp News MySQL Json HowTos JavaScript FTP S3


Code2care is an initiative to publish and share varied knowledge in programming and technical areas gathered during day-to-day learnings and development activities.

Students and Software Developers can leverage this portal to find solutions to their various queries without re-inventing the wheel by referring to our easy to understand posts. Technical posts might include Learnings, Tutorials, Trouble-Shooting steps, Video Tutorials, Code Snippets, How Tos, Blogs, Articles, etc.
🎉 We are celebrating the 10th years of Code2care! Thank you for all your support! We hope we made a difference.
We strong support Gender Equality & Diversity.

We stand in solidarity with Ukraine - Make a donation to UNHCR -