def replace(self, query):
if query.startswith("#"):
query = query[1:]
views = self.window.views()
else:
views = [self.window.active_view()]
total = 0
for view in views:
original_string = view.substr(sublime.Region(0, view.size()))
pp = '\\b' + self.original_text + '\\b'
p = re.compile(pp)
(new_string, count) = p.subn(query, original_string)
total = total + count
if new_string != original_string:
view.run_command('replace_content', {"new_content": new_string})
sublime.status_message("Replace {0} occurrences from {1} files".format(total, len(views)))
pass
评论列表
文章目录