Skip to content
Advertisement

How to search and get rid of this character?

Bulmaca-Zeka Oyunu<200f>

I have a lot of strings in a text file, and I noticed that one has this <200f> char. I want to find all entries that have this char and remove it. But in Vim I can’t find it by searching ‘<200f>’ using the search string ‘<200f>’. Probably it is one char not 6 individual chars.

In Python or VIM, how to remove or search them?

Advertisement

Answer

Those literal characters in angle brackets are how Vim handles some problematic unprintable characters. They are quite puzzling at first but they are really easy to figure out because they simply spell out the character’s hexadecimal code.

In this case, <200f> is the literal representation of U+200F, which you search like this:

/%u200f

So, if you want to get rid of the occurrences of <200f> in the current buffer, all you have to do is:

:%s/%u200f//g

See :help %u.

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement