Amit Acharya
Amit Acharya

Reputation: 461

How to replace all occurences of a text in vim where the characters in the text are unicode characters?

How to replace all occurences of a text in vim where the characters in the text are unicode characters, for example snippet

each¬ 4 ▸ ▸ <% ${1:collection}.each do |${2:member}| -%>¬ 5 ▸ ▸ ▸ ▸ ${3}¬ 6 ▸ ▸ <% end -%>¬

I want to replace all the ▸ ▸ occurences with empty string, I tried s/▸ ▸//g and even the unicode for which is U+25B8 but doesn't seem to work, or am I doing this wrong?

Upvotes: 1

Views: 145

Answers (1)

Ingo Karkat
Ingo Karkat

Reputation: 172520

There are many ways. If you want to match all non-ASCII characters, that'll be [^\x00-\x7F].

For a particular one (say, U+25B8; the ga command is useful to tell you the current character's code), you can:

  • just yank it, and insert it in the command-line search via <C-R>" (that's Ctrl + R, followed by ")
  • insert it via <C-V>u25b8 in the command-line
  • use the special \%u25B8 atom

Upvotes: 2

Related Questions