The Computer Oracle

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

--------------------------------------------------
Hire the world's top talent on demand or became one of them at Toptal: https://topt.al/25cXVn
--------------------------------------------------

Music by Eric Matyas
https://www.soundimage.org
Track title: Cosmic Puzzle

--

Chapters
00:00 How To Select A Whole Html Block, Including The Tags In Vim?
00:16 Answer 1 Score 8
00:28 Accepted Answer Score 11
00:54 Thank you

--

Full question
https://superuser.com/questions/450766/h...

--

Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...

--

Tags
#vim #selection

#avk47



ACCEPTED ANSWER

Score 11


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



ANSWER 2

Score 8


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

See:

:help text-objects
:help v_at