Regular Expression Notepad increment numbers in every line

情到浓时终转凉″ 提交于 2019-11-27 05:43:22

问题


I've to add numbers incrementally in the beginning of every line using Notepad++. It is the not the very beginning. But, like

  when ID = '1' then data
  when ID = '2' then data
  when ID = '3' then data
  .
  .
  .
  .
  when ID = '700' then

Is there any way i can increment these numbers by replacing with any expression or is there any inbuilt-notepad functions to do so.

Thanks


回答1:


If you want to do this with notepad++ you can do it in the following way.

First you can write all the 700 lines with template text (you can use a Macro or use the Edit -> Column Editor). Once you have written it, put the cursor on the place you want the number, click Shift+Alt and select all the lines:




回答2:


It's not possible to accomplish this with a regular expression, as you will need to have a counter and make arithmetic operations (such as incrementing by one).




回答3:


You can try the cc.p command of ConyEdit. It is a cross-editor plugin for the text editors, of course including Notepad++.

With ConyEdit running, copy the text and the command line below, then paste:

when ID = '#1' then data
cc.p 700

Gif example



来源:https://stackoverflow.com/questions/25428620/regular-expression-notepad-increment-numbers-in-every-line

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!