How to edit all lines in Visual Studio Code

Here is an easy way to do this:

  1. Ctrl+A to select all or select your desired text.

  2. Shift+Alt+I to put a cursor at the end of each line.

  3. Type your ' (or whatever you want at the end).

  4. Home will move all your cursors to the beginning of the lines.

  5. Type your ' (or whatever you want at the beginning of all the lines).


You could edit and replace with a regex:

Find (Ctrl+F):

^(.+)$

Replace:

'$1'

This regex finds any content on a line and wraps it inside quotes. The $1 refers to whatever is matched inside the parentheses in the regex. In this case, it's "one or more characters" i.e. everything on the line. Be sure to tick the regex icon.

Video demonstration of the replacement

If every line may or may not have a space before the content, and you want every line to have a space, try this:

Find:

^ ?(.+)$

Replace (notice the space before the first quote):

 '$1'