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

Published on Jul 04, 2021

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. 🙂

Comments (0)