How to Add Text at Start and End of Every Line in VS Code

Published on July 4, 2021 26 sec read

Hello artisans, sometimes we need to enter text/code at the start and end of every line. We can do it easily with Visual Studio Code. I’m testing on Windows 10.

Table of Contents

  1. Problem
  2. Solution

Problem

I’m taking a text file. We are going to insert text at the start and end of every line.

Solution

Open the file and type CTRL + H. In the search bar, type ^(.+)$ and press the regular expression button:

In the replace field, write your desired text/code before and after $1. Let’s take a look at an example. We are going to add START:: text at the start and ::END text at the end of every line:

We’re done. You can see the output.

That’s it. Thanks for reading. 🙂

Monthly Newsletter

One email a month, packed with the latest tutorials, delivered straight to your inbox.
We'll never send any spam or promotional emails.
Author

Hey, I'm Md Obydullah. I build open-source projects and write article on Laravel, Linux server, modern JavaScript and more on web development.

Follow