The specifics of what you’re asking would depend on the nature of the code and without a sample its difficult to suggest exactly.
So if you have something like this:
<div class="question">
...
</div>
<div class="question">
...
</div>
<div class="question">
...
</div>
<div class="question">
...
</div>
<div class="question">
...
</div>
- Select <div class="quest (something unique enough to match all the divs you want to wrap)
- Press Ctrl+D several times to multiselect them, or press Alt+F3 to multiselect them all. You now have multiselections and multicursors.
- Press home and down. Selections disappear and your cursors are in-between each div
- Press Ctrl+Shift+A twice. Now your
…
blocks are fully selected as separate selections.
- Press Alt+Shift+W to wrap each div block with a new tag. By default its a
, but if you start typing the tag will be whatever you type.
- Optional, step 5 creates fields, so you can tab to highlight the contained div blocks again etc. Hit escape to break out of field mode.
The above should give you some workflow ideas for achieving what you need. If your divs all vary slightly, in place of step 1 you can use Find (Ctrl+F), optionally with a regex, and press “Find All” to match the divs you want to wrap.
Following the above with a few extra keystrokes it’s very easy to get to this, with 5 or 100 divs:
<form onsubmit="func()">
<div class="question">
...
</div>
</form>
<form onsubmit="func()">
<div class="question">
...
</div>
</form>
<form onsubmit="func()">
<div class="question">
...
</div>
</form>
<form onsubmit="func()">
<div class="question">
...
</div>
</form>
<form onsubmit="func()">
<div class="question">
...
</div>
</form>
Lastly if you’re regularly creating markup with lots of repeating stuff, take a look at the Emmet plugin. A massive timesaver, it allows you to use CSS style syntax to generate large blocks of markup quickly. Eg. the above code block could be created simply by typing
(form[onsubmit="func()"]>div.question>p)*5
and hitting TAB with the cursor after the 5. This cheat sheet gives you info about what you can do with Emmet. Enjoy!