Reputation: 941
I'm trying to replace
underline{someword}
with
underline{someword.}
in Vim.
I've tried
:%s/underline{\w*}/underline{$1\.}/g
but it changes the matched patterns to
underline{$1.}
Why? How do I fix this?
Upvotes: 0
Views: 59
Reputation: 3086
Use the ever-underappreciated \zs
and \ze
:
:%s/\munderline{\w*\zs\ze}/./g
Upvotes: 3
Reputation: 785856
You can use grouping:
:%s/\(underline{\w*\)}/\1\.}/g
Here \(...\)
is used for grouping the match.
Upvotes: 3
Reputation: 2834
You forgot the capture group
:%s/underline{\(\w*\)}/underline{\1\.}/g
Upvotes: 3