0

How to find all occurrences of word or a character and select them once and edit using multi cursor in visual studio code?

I have list of users and need to add domain before names.

I have:

abc
pqr
xyz

I want :

domain\abc
domain\pqr
domain\xyz

I want to search for a new line character which will take me to the end of the each user name then by pressing home button I should reach to the beginning of each user where I will type "domain\" and it will modify each user at once.

I was able to do this in sublime text 3 by find all feature which provides multi cursor at each occurrence of character.

Is there any way to do the same in VS code ?

Akshay Naik
  • 669
  • 1
  • 6
  • 22

2 Answers2

1

The easiest way to achieve this doesn't involve searching for newlines but rather by

  1. Making a selection (Such as Ctrl+A)
  2. Add cursor to all lines of the selection (Alt+Shift+I)
  3. Pressing home (Home)
fanduin
  • 1,149
  • 10
  • 17
0

You can use search and replace with a simple regular expression.

Search for: ^(.+)$

Replace with: domain\\$1

Make sure to enable regular expressions (Alt+R).

Bill_Stewart
  • 22,916
  • 4
  • 51
  • 62