Search This Blog

2023/04/29

How to add text at start and end of every line in Visual Studio Code

 If in Visual Studio Code you want to add fixed string to start and end of

line in replace window obtained by
Ctrl + H add following regular express also use regular expression
replace option by clicking on third option with *. after first textbox

^(.+)$

then in second textbox add the text you want to add at start of line then
$1 after
that add text you want to add at end of line
e.g.

there is on editor we want to construct a insert statement using this
Italian cuisine

so replace string will be

INSERT INTO Cuisine(name,createdAt,updatedAt) values('$1',now(),now());

Here first part is

INSERT INTO Cuisine(name,createdAt,updatedAt) values('

second part is $1

third part is

',now(),now());

final output will be

INSERT INTO Cuisine(name,createdAt,updatedAt) values('Italian cuisine',
now(),now());

No comments:

Post a Comment