Gattoo
Gattoo

Reputation: 3079

how to highlight entire <DIV> </DIV> in Vim?

I am using the latest Vim in Ubuntu and Vimrc by Vincent Driessen of nvie.com. How do I highlight the entire section between matching pair of div and /div? The DIV tag on the same line is highlighted when I am on < of the DIV tag, but I want to highlight the entire section, to see if divs are matched all over the page, one by one.

Upvotes: 6

Views: 1926

Answers (2)

Flavio Oliveira
Flavio Oliveira

Reputation: 419

On the <div> type: v a t

What vat does:

v : Starts visual mode (selects text).

a : Means "a" text object, including the surrounding delimiters (in this case, the and tags themselves).

t : Stands for "tag" and tells Vim to select the entire block within and including the matching tags.

So, when you press vat, Vim:

Selects the entire section between the matching <div> and </div> tags. Highlights the block, including the tags themselves.

Upvotes: 0

Zsolt Botykai
Zsolt Botykai

Reputation: 51603

Move to the starting <div> tag, then hit vat.

Upvotes: 13

Related Questions