Wrap each block of text in a tag

I am starting a new project from frontend mentor. Usually the site lets you download a starter folder, that has some starter essentials to help you, but a thing I don't like is that they let there a raw html. I was wondering, is there a way to wrap each block of these texts in some tag with vscode? So I don't have to do each for each one
No description
23 Replies
Jochem
Jochem3mo ago
Search and replace on the empty lines using a regex You might also be able to multi select and use the wrap with Emmet abbreviation command, not sure
Jochem
Jochem3mo ago
Not at my pc at the moment. Something like searching for ^$ with regex matching on
Pi, a future fluent jp speaker
i c gonna search about thx
Jochem
Jochem3mo ago
Share the raw text, I'll take a look when I'm back at my pc
ἔρως
ἔρως3mo ago
^(.+)$ <-- search <p>$1</p> <-- replace https://regex101.com/r/9W8ED5/1
Pi, a future fluent jp speaker
Desserts Waffle with Berries Waffle 6.50 Add to Cart Vanilla Bean Crème Brûlée Crème Brûlée 7.00 Add to Cart Macaron Mix of Five Macaron 8.00 Add to Cart Classic Tiramisu Tiramisu 5.50 Add to Cart Pistachio Baklava Baklava 4.00 Add to Cart Lemon Meringue Pie Pie 5.00 Add to Cart Red Velvet Cake Cake 4.50 Add to Cart Salted Caramel Brownie Brownie 4.50 Add to Cart Vanilla Panna Cotta Panna Cotta 6.50 Add to Cart Your Cart (<!-- Quantity -->) Your added items will appear here
ἔρως
ἔρως3mo ago
if you want to ignore the spaces, use this: ^ *(.+) *$
pangalan1
pangalan13mo ago
highlight something first and then use Ctrl + Shift + L after that, use Ctrl + Shift + P or press F1 and search Emmet: Wrap with Abbreviation no need for the regex and fancy stuff, emmet is your friend here The way Ctrl + Shift + L works is that if you select a part of text, it will search for other text containing what you selected Lets say you higtlighted the word "balls" and then press Ctrl + Shift + L, After pressing the keyboard shortcut, you will be able the edit text containing the world "balls". You can add spacings, letters, quotations whatever you want
pangalan1
pangalan13mo ago
pangalan1
pangalan13mo ago
pangalan1
pangalan13mo ago
heres how I would do it based on your example i still don't get why you would need regex for this tho another use case of the Ctrl + Shift + L is that you can change all elements classname with the same classname. Ex, I have 10 <li class="header_listItem">. I can highlight the classname and be able to edit them all
ἔρως
ἔρως3mo ago
this doesnt work: ctrl + shift + l only selects multiple instances of the same selected text/search and none of the text is the same
pangalan1
pangalan13mo ago
"Add to Cart" is and you can use arrow and shift key to highlight text You can see it in my 2nd demo vid
ἔρως
ἔρως3mo ago
yes, that works but the first and last 2 lines have to be done manually
pangalan1
pangalan13mo ago
i dont think so, check my video. you can select all of the them
ἔρως
ἔρως3mo ago
they do, because everything you do relies on repeated text
pangalan1
pangalan13mo ago
i agree that regex does work in some situations but ctrl + shift + l works perfectly fine here i'm not saying you should use ctrl + shift +l all the time on more advanced stuff but it cuts it
ἔρως
ἔρως3mo ago
im saying that your method works for almost everything in the input, but not everything it has the advantage of being easier to do, quick, simple and you can easily correct if something is wrong however, it cant do much for things that dont have a repeating pattern
pangalan1
pangalan13mo ago
ah ok, all good
Chen
Chen3mo ago
May I help you?
Jochem
Jochem3mo ago
if you can help, just help here in open chat. The only help we allow on the server is given freely
Chen
Chen3mo ago
I will help freely.
Want results from more Discord servers?
Add your server