I want to no a way around that copy-paste thing

I do practise and code in VSCode.
Sometimes for ex: like I am working in the body part and then it came to my mind that I should put this whole in a div and then I would select that whole and then remove it, will make a new div and then paste the whole thing in it.
I knows its not that big deal but I am curious to know if there is a way around it. So that I can just select the whole thing and the editor would do the copy paste thing for me!
Please tell if you know about it.
And also though VSCode is a very awsome editor but is there any other editor better than VSCode.

Thank You!

I don’t know about this type of feature, but there’s a simple hack…
Instead of cut pasting whole data, why you could just put <div> at start and </div> at end…

You can do it with Emmet: Wrap with Abbreviation to a keyboard shortcut. You will need Emmet installed in VS Code. It may be default, I can’t remember.
It allows you to select content, and then wrap it in opening and closing tags.

  1. In Code, File > Preferences > Keyboard Shortcuts
  2. Search for Emmet: Wrap with Abbreviation
  3. Double click that line.
  4. Set your keyboard shortcut.

To wrap the selection in <div></div>,

  1. select your content
  2. press your shortcut from the previous steps.
    You will see a text box open at the top of VS Code - Enter Abbreviation. (I cannot take a screenshot with the box open.
  3. Just type in ‘div’. NO < or >.
    You will see the tags appear above and below the selection.
  4. Press [ENTER]
1 Like

As I mentioned I code in VSCode, and in this editor there is a feature of auto completion of tags. It is an amazing feature but sometimes like in the situation above it annoys me a lot.
So that’s what I am asking about!
Thanks for sharing your views :slight_smile:

@leebut Thank you so much brother :slight_smile:

Thank you!! It’ll be life saving for me too in lot of cases

You’re both welcome.

I remember a while back when I was searching around for a way to do the same thing. It took a while to find out what to do, so I’m happy to help people not spend that time.

1 Like