why vim script change inside visual area not work?

Posted by avalan_che on Super User See other posts from Super User or by avalan_che
Published on 2013-10-26T07:58:24Z Indexed on 2013/10/26 9:58 UTC
Read the original article Hit count: 171

Filed under:
|

Say a webpage like this:

...
<div class="block">
    <p>...</p>
    <p>...</p>
</div>
<p>...</p>
...

I tried to add class="cls" to <p>s inside <div class="block">, so I did:

while search('div class="block"','W') > 0
    normal vat    
    '<,'>s@<p>@<p class="cls">@gec
endw

but this wouldn't work as expected: those <p>s outside <div class="block"> got changed too. In command window these lines totally work, why not putting together?

© Super User or respective owner

Related posts about vim

Related posts about script