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

查看:131
本文介绍了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"
        },
       ...
     ]

现在,我想开始将ID从0而不是1开始递增.如何使用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.

推荐答案

通过执行以下步骤解决了该问题:

Solved it by doing these steps:

  1. 进行查找并替换正则表达式"ID" : "\d+",然后将其替换为文件中任何地方都不存在的字符串(我将其替换为"ID" : "xyz"
  2. "ID" : "xyz"
  3. 上进行多项选择
  4. 在多项选择中使用文本糕点插件数字序列(\ 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天全站免登陆