post image :date_long | 1 min Read

Vim increment number at irregular rows

[{
    "payload": {
        "data": {
            "vlan_id": 27,
            ...
        }
    },
    "_response": 200,
    ...
    "_iteration": 0           <---
}, {
    "payload": {
        "data": {
            "vlan_id": 27,
       ...
        }
    },
    "_response": 400,
    ...
    "_iteration": 0.         <---

:let c=1 | g/_iteration/ s/\d\+/\=c/ | let c+=1

**Result''

[{
    "payload": {
        "data": {
            "vlan_id": 27,
            ...
        }
    },
    "_response": 200,
    ...
    "_iteration": 1
}, {
    "payload": {
        "data": {
            "vlan_id": 27,
       ...
        }
    },
    "_response": 400,
    ...
    "_iteration": 2

...

author image

Jan Toth

I have been in DevOps related jobs for past 6 years dealing mainly with Kubernetes in AWS and on-premise as well. I spent quite a lot …

comments powered by Disqus