Sublime Text 2 增量数字 [英] Sublime Text 2 increment numbers

查看:28
本文介绍了Sublime Text 2 增量数字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个如下所示的 JSON 文件:

I have a JSON file that looks like this:

    "Algeriet" :
    [
        {
            "name" : "Nyårsdagen",
            "date" : "2013-01-01",
            "ID" : "1"
        },
        {
            "name" : "Mawlid En Nabaoui Echarif",
            "date" : "2013-01-24",
            "ID" : "2"
        },
        {
            "name" : "Första maj",
            "date" : "2013-05-01",
            "ID" : "3"
        },
       ...
     ]

现在我想从 0 而不是 1 开始增加 ID.如何使用 Sublime Text 2 做到这一点?我已经安装了 Text Pastry 插件,但我不确定如何选择文本中的 ID,以便我可以替换这些值.

Now I would like to begin incrementing the IDs from 0 instead of 1. How can I do this with Sublime Text 2? I have installed the Text Pastry plugin but I'm not sure how to select the IDs in the text so that I can replace these values.

推荐答案

通过以下步骤解决了:

  1. 查找并替换正则表达式 "ID" : "d+" 并将其替换为我知道文件中任何位置都不存在的字符串(我将其替换为 "ID" : "xyz"
  2. ID"进行多选:xyz"
  3. 在多选上使用Text Pastry插件数列(i)"
  1. Do a find and replace for regex "ID" : "d+" and replacing it with a string which I know does not exist anywhere in the file (I replaced it with "ID" : "xyz"
  2. Make a multiple selection on "ID" : "xyz"
  3. Using the Text Pastry plugin "Number Sequence (i)" on the multiple selection

这篇关于Sublime Text 2 增量数字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆