Reputation: 1057
Is it possible to use vim to replace the 'http://google.com/' and other links to '#'?
<a class="link1" href="http://google.com/">My Link</a>
<a class="link1" href="http://yahoo.com/">My Link</a>
<a href="http://stackoverflow.com/">My Link</a>
to
<a class="link1" href="#">My Link</a>
<a class="link1" href="#">My Link</a>
<a href="#">My Link</a>
Thanks
Upvotes: 3
Views: 809
Reputation: 37279
This one should handle the basic http
case:
:%s/http:\/\/[^\"]*/#/g
But this should be more flexible - the general idea is to find instances of href="
, save that as a group, then match until we hit another "
. Then we replace it with our group (\1
) and the hash sign:
:%s/\(href=\"\)[^\"]*/\1#/g
Upvotes: 5