How to select a whole HTML block, including the tags in VIM?

6

1

Suppose I have:

<div id="help">
    <table>
        ...
        ...
        ...
    </table>
</div>

How do I select the whole block, starting from <div id="help">?

Kay

Posted 2012-07-19T03:34:21.243

Reputation: 175

Answers

5

vat, as in Heptite's answer is the way to go.

Note that, depending on where the cursor is, you may need to type at a few more times until the whole <div> is selected.

Supposing the cursor is in a <td> you'd need vatatatat to select the whole <div>:

<div>      ^  at
  <table>  |  at
    <tr>   |  at
      <td> | vat

Another option would be to search backward for di(v) or he(lp) and select the whole tag with vat:

?di<CR>vat

romainl

Posted 2012-07-19T03:34:21.243

Reputation: 19 227

3

Place your cursor within the opening or the closing tag and type "vat".

See:

:help text-objects
:help v_at

Heptite

Posted 2012-07-19T03:34:21.243

Reputation: 16 267