Matthew Daly
Matthew Daly

Reputation: 9476

Removing hex code ffa3 in Vim

I've got a file with a load of weird characters with in it that I need to get rid of.

Using ga on the character reveals it has the following encodings:

ᆪ> 65443, Hex ffa3, Octal 177643

But I can't seem to find it using :%s/\%xffa3//g. What am I doing wrong?

Upvotes: 1

Views: 168

Answers (1)

Ingo Karkat
Ingo Karkat

Reputation: 172540

Look at :help \%x:

\%x2a Matches the character specified with up to two hexadecimal characters.

So Vim is actually matching the three characters <uf>a3. Since you have a four-digit hex number, you need to use \%u:

:%s/\%uffa3//g

Alternatives

You can also insert the character directly into the command line via :help i_CTRL-V_digit (i.e. <C-v>uffa3), but if you already have instances of that character in your buffer (and near your cursor!), I'd just yank that char with yl and insert it in the command-line via <C-r>".

Upvotes: 3

Related Questions