utilities.py 文件源码

python
阅读 33 收藏 0 点赞 0 评论 0

项目:sublimeplugins 作者: ktuan89 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号