Thursday, August 30, 2018

Re: How can i add the same string to many lines ?

On 08/30/2018 10:01 AM, Antharia Jack wrote:
> Hello everyone ?

Hi,

> I would like to add target="_blank" to all my href in a html file.

Okay. That seems odd, but you do your own thing.

> I would like to say to vim : add this string after the second " symbol
> of each line where is the word href.

Can you provide an example?

I'd be inclined to try a regular expression like the following.

:%s/<a href=\(.\{-1,}\)>/<a href=\1 target="_blank">/g

Use a non-greedy wildcard match to find an anchor tag (assuming it
starts with href) and append the target="_blank" to the end.

> For now i just use the dot command to each line.

That's annoying, especially if you have a LOT of anchor tags to change.

> Thanks for reading.

:-)



--
Grant. . . .
unix || die

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment