bencel1990
bencel1990

Reputation: 56

Is there any way in vim to jump to lines with certain number of occurences of a character?

I am trying to use a macro and I would need to jump to lines only with certain number of occurred characters. Why I need this? I want to make modifications in a HTML code, but only on lines where the div class attribute is set and nothing else.

So match these:

<div class="div_class"></div>

And don't want to match these:

<div class="div_class" style="width: 100px"></div>

It is a boilerplate code, that is why I need to restructure it. I was thinking of matching lines in a macro with only two "'s. I can accept other alternatives.

Upvotes: 1

Views: 73

Answers (1)

Wilson Wong
Wilson Wong

Reputation: 406

How about: /\vclass\="(\w|\s|-)*"\s*\>

This will match:

<div class="div_class"></div>

<div class="div_class asdf"></div>

<div class="div_class asdf spinal-classname"></div>

Upvotes: 4

Related Questions