IT Nota

  • Home
  • How To
  • .NET
  • WordPress
  • Contact

How to Add Comma to Each Line Using Visual Studio Code or Sublime Text

Sometimes the simplest thing is really taken for granted and we take the long route to do the simplest thing. We received a CSV with thousands of ID numbers that will be used to update a database table. The data would look like the following:

  87295
  86719
  31695
  94836
  17957
  69783
  57168
  96874
  12853
  92816
  ...
  [deleted for brevity]
  ...

Open a text file in Visual Studio Code

The goal is just to add a comma at the end of each line so it can be used to update data in a database table.

In the past, we would probably write a macro module in Excel, but other than a security risk, it’s overcomplicating a simple task.

Using either Visual Studio Code or Sublime Text, we can accomplish this task in a matter of seconds. No writing macros required.

1. Use the Search and Replace Control

This works the same way in both Visual Studio Code and Sublime Text. The only difference is the shortcuts between PC and Mac.

PC

  1. Press CTRL+H for Replace.
  2. Type in $ in Find, and , in Replace.
  3. Make sure Regular Expression is turned on (ALT+R)
  4. Replace All by pressing CTRL+ALT+ENTER.

Mac

  1. Press Option+Command+F for Replace.
  2. Type in $ in Find, and , in Replace.
  3. Make sure Regular Expression is turned on (Option+Command+R)
  4. Replace All by pressing Option+Command+ENTER.

Visual Studio Code Search and Replace All with Regex

2. Use Multi-Line Editing

Visual Studio Code

  1. Select all by pressing CTRL+A (or Command+A for Mac).
  2. From Selection, choose Add Cursors to Line Ends by pressing SHIFT+ALT+I (or SHIFT+OPTION+I).
  3. Type the Comma character.

Visual Studio Code Selection Add Cursors to Line Ends

Sublime Text

  1. Select all by pressing CTRL+A (or Command+A for Mac).
  2. From Selection, choose Split into Lines by pressing CTRL+SHIFT+L (or COMMAND+SHIFT+L).
  3. Move the cursors at the end of lines by pressing End on Windows or Right Arrow on macOS.
  4. Type the Comma character.

Whatever method you use, the end result will look like the following:

Text file with commas in Visual Studio Code

Further Reading

How to Reassign Shortcut Key for Column Selection in Visual Studio Code
How to Reassign Column Selection Shortcut Keys in Sublime Text
Adding Comma to Each Line Using Sublime Text 2
How to Open Visual Studio Code from command line macOS

October 5, 2021 Filed Under: How To Tagged With: Code Editor, Sublime Text, Visual Studio Code

Buy me a coffee?

Buy me a coffee If you find any of the articles or demos helpful, please consider supporting my work here, you'll have my big thanks!

Buy me a coffee Support this site
Buy Me a Coffee?

Categories

  • .NET
  • Coding
  • Cybersecurity
  • Database
  • How To
  • Internet
  • Multimedia
  • Photography
  • Programming
  • Resources
  • Review
  • Tips and Tricks
  • Uncategorized
  • Use Case
  • WordPress
  • Writing

Recent Posts

  • How to View Stored Procedure Code in SQL Server
  • How to Find a String in SQL Server Stored Procedures
  • How to Remove Cached Credentials without Rebooting Windows
  • ESP Work Automation: Empowering Enterprises with Streamlined Workflows and Operational Efficiency
  • How to Search for a String in All Tables in a Database

Recent Posts

  • How to View Stored Procedure Code in SQL Server
  • How to Find a String in SQL Server Stored Procedures
  • How to Remove Cached Credentials without Rebooting Windows
  • ESP Work Automation: Empowering Enterprises with Streamlined Workflows and Operational Efficiency
  • How to Search for a String in All Tables in a Database

Tags

.NET .NET Core AdSense ASP.NET Cdonts Dll Classic ASP Code Editor ETL FSharp Genesis Framework Git Google HP Asset Manager HTML5 Hugo IIS Information Security Internet Internet Information Services iOS JAMStack Linux macOS Microsoft Microsoft SQL Server MVC PHP PowerShell Python Simple Mail Transfer Protocol Smtp Server SQL SQL Server SSIS SSMS SSRS Sublime Text Visual Studio Visual Studio Code VPN Windows Windows 8 Windows 10 Windows 2012 Windows Server

Copyright © 2011-2025 IT Nota. All rights reserved. Terms of Use | Privacy Policy | Disclosure