How to Remove u200b

Remove

Search regular expression \x{200b}.
\u200b cannot match it in SublimeText.

u200b (ZERO WIDTH SPACE)

UTF-8 (hex) 0xE2 0x80 0x8B (e2808b)
UTF-16 (hex) 0x200B (200b)

SublimeText Plugin

Preferences -> Browse Packages. Put the following two files under User.

x_u200b_killer.py

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import sublime, sublime_plugin

class ShowU200b(sublime_plugin.EventListener):
def on_modified_async(self, view):
u200b_regions = view.find_all('\u200b')
if len(u200b_regions) > 0:
view.add_regions("u200b_regions", u200b_regions, "string", "circle")
view.show_popup('U200B Detected!!!')
else:
view.erase_regions("u200b_regions")


class RemoveU200b(sublime_plugin.TextCommand):
def run(self, edit):
print('Removing U200B')

regions = self.view.find_all('\u200b')
for r in reversed(regions):
self.view.erase(edit, r)

x_u200b_killer.sublime-commands

1
2
3
[
{ "caption": "Remove U200b", "command": "remove_u200b" },
]

Reference

Unicode Character ‘ZERO WIDTH SPACE’ (U+200B)
delete U+200B zero-width space characters using sublime text 3