Skip to content

VS Code: Add Comma to Each Line

Let’s assume the following scenario:

You’ve received a file with a list of company IDs, and you’ll need to upload the file either into the database or into an admin panel system.

But before you upload the file, you need to ensure that all the IDs are separated by commas.

If the file contains only a few IDs, sure you can add the commas manually.

But what if the file contains thousands of IDs?

Well, in this case, you can easily and quickly add the commas with VS Code.

Let’s get to it!

Use Find and Replace

  1. Press down CTRL + H to open the Find window.
  2. Type in $ in the Find field
  3. Type in , (comma) in the Replace field
  4. Turn on Regular Expression (ALT + R)
  5. Click Replace All (CTRL + ALT + ENTER)
VS Code Find and Replace feature

🎥 Prefer a video walkthrough instead? Check this out:

Multi-line Editing

  1. Select all the IDs by pressing down CTRL + A
  2. Go to Selection and choose Add Cursors to Line Ends
  3. Type the , comma character

That was it 🥳

If you know any other ways to add the comma, please leave the steps in the comment section. 💜


Let me know what you think about this article in the comments section below.

If you find this article helpful, please share it with others and subscribe to the blog to support me, and receive a bi-monthly-ish e-mail notification on my latest articles.   
  

Comments