sublime text 3 插件开发 中的 替换

 

说明:加号+居然要加斜杠才能find到(\+)

find    \"   要写成   \\\\\"  

command 名字大小写 不区分

以下这段 插件 是 专门转换 WCF Test Client(VS官方提供的wcf测试程序) 程序所提取的json数据

配置了热键后可一键转换





import sublime
import sublime_plugin


class autoreplaceformatjsonCommand(sublime_plugin.TextCommand):
    def run(self, edit):
        for region in reversed(self.view.find_all('''\" \+\n    \"''')):
            if not region.empty():
                print(region)
                self.view.replace(edit, region, '')
        for region in reversed(self.view.find_all('\\\\\"')):
            if not region.empty():
                print(region)
                self.view.replace(edit, region, '\"')
        self.view.replace(edit, sublime.Region(0, 1), '')
        self.view.replace(edit, sublime.Region(self.view.size() - 1, self.view.size()), '')
        self.view.run_command('pretty_json')

 

转载于:https://my.oschina.net/raddleoj/blog/879187

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值