I'm trying to find all instances of a Twitter handle, and wrap an anchor tag around them.
:%s/\(@[\w]\)/<a href="http://www.twitter.com/\1">\1<\/a>/gc
Which gives me:
E488: Trailing characters
When the separator character (/
in your case) between {pattern}
and {string}
is contained in one of those, it must be escaped with a \
. A trick to avoid that is to use a different separator character, e.g. #
:
:%s#@\(\w\+\)#<a href="http://www.twitter.com/\1">\0</a>#gc
PS: If it should do what I think it should do, your pattern is wrong; see my correction.
If you have this when replacing within a selected block of text, it may be because you mistakenly typed %s
when you should only type s
I had this happen by selecting a block, typing :
and at the prompt :'<,'>
, typing %s/something/other/
resulting in :'<,'>%s/something/other/
when the proper syntax is :'<,'>s/something/other/
without the percent.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With