Reputation: 2283
I have a strange character in a text, how can I find all of its occurrences and replace it with another character?
I know that if you need to do the same thing with a word you can use *
and then :%s//replacement/g
to replace all occurrences,
is there something similar for characters?
Upvotes: 1
Views: 203
Reputation: 971
Yank the character into a register (a
in this case): "ayl
Start your substitute command :%s/
Use <C-r>
a
to paste the register into the command line.
Finish your command and execute: :%s/<char>/<new-char>/g
Upvotes: 1
Reputation: 791
Use the command:
%s/a/A/g
which replaces a
with A
. For some more examples of the %s
command take a look here.
Upvotes: 0
Reputation: 5654
Do you know how to type out the character? If so you can do :%s/<char-to-replace>/<char-to-replace-with/g
Upvotes: 0