Vim - incremental numbering via regular expression search and replace

前端 未结 3 1077
太阳男子
太阳男子 2020-12-11 14:13

I have this code:

array (\'id\' => 1, \'name\' => \"Murka\", \'date_of_birth\' => \"2014-10-31\", \"breed_id\" => 1),
array (\'id\' => 1, \'na         


        
3条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-11 14:40

    I don't have an answer to your general question, but I do have one for your specific situation. You can make your command work by putting the comma into a positive look-ahead, like this:

    :let i=1 | g/1(\,\)\@=/ s//\=i/ | let i+=1
    

    Now it will only replace the 1.

提交回复
热议问题