Real Vim ninjas count every keystroke - do you?

Pick a challenge, fire up Vim, and show us what you got.

Changelog, Rules & FAQ, updates: @vimgolf, RSS.

Your VimGolf key: please sign in

$ gem install vimgolf
$ vimgolf setup
$ vimgolf put 9v0067255515000000000597

Nested JSON Flattener

Transform a deeply nested JSON structure into a flattened key-value format where each path is represented by dot notation

Start file
{
  "company": {
    "details": {
      "name": "TechCorp",
      "founded": 1995,
      "isPublic": true
    },
    "locations": {
      "headquarters": {
        "address": {
          "street": "123 Innovation Way",
          "unit": "4B",
          "city": "San Francisco",
          "state": "CA",
          "zip": "94105"
        },
        "coordinates": {
          "lat": 37.7749,
          "lng": -122.4194
        }
      },
      "branches": {
        "europe": {
          "primary": {
            "city": "London",
            "employees": 250,
            "opened": "2020-01-15"
          },
          "secondary": {
            "city": "Berlin",
            "employees": 120,
            "opened": "2021-03-01"
          }
        },
        "asia": {
          "primary": {
            "city": "Tokyo",
            "employees": 180,
            "opened": "2019-11-30"
          }
        }
      }
    },
    "metrics": {
      "financial": {
        "revenue": {
          "2021": 1500000,
          "2022": 2200000,
          "2023": 3100000
        },
        "expenses": {
          "2021": 1200000,
          "2022": 1800000,
          "2023": 2500000
        }
      },
      "performance": {
        "goals": {
          "q1": 85,
          "q2": 90,
          "q3": 88,
          "q4": 92
        }
      }
    }
  }
}
End file
company.details.name=TechCorp
company.details.founded=1995
company.details.isPublic=true
company.locations.headquarters.address.street=123 Innovation Way
company.locations.headquarters.address.unit=4B
company.locations.headquarters.address.city=San Francisco
company.locations.headquarters.address.state=CA
company.locations.headquarters.address.zip=94105
company.locations.headquarters.coordinates.lat=37.7749
company.locations.headquarters.coordinates.lng=-122.4194
company.locations.branches.europe.primary.city=London
company.locations.branches.europe.primary.employees=250
company.locations.branches.europe.primary.opened=2020-01-15
company.locations.branches.europe.secondary.city=Berlin
company.locations.branches.europe.secondary.employees=120
company.locations.branches.europe.secondary.opened=2021-03-01
company.locations.branches.asia.primary.city=Tokyo
company.locations.branches.asia.primary.employees=180
company.locations.branches.asia.primary.opened=2019-11-30
company.metrics.financial.revenue.2021=1500000
company.metrics.financial.revenue.2022=2200000
company.metrics.financial.revenue.2023=3100000
company.metrics.financial.expenses.2021=1200000
company.metrics.financial.expenses.2022=1800000
company.metrics.financial.expenses.2023=2500000
company.metrics.performance.goals.q1=85
company.metrics.performance.goals.q2=90
company.metrics.performance.goals.q3=88
company.metrics.performance.goals.q4=92

View Diff

1,67c1,29
< {
<   "company": {
<     "details": {
<       "name": "TechCorp",
<       "founded": 1995,
<       "isPublic": true
<     },
<     "locations": {
<       "headquarters": {
<         "address": {
<           "street": "123 Innovation Way",
<           "unit": "4B",
<           "city": "San Francisco",
<           "state": "CA",
<           "zip": "94105"
<         },
<         "coordinates": {
<           "lat": 37.7749,
<           "lng": -122.4194
<         }
<       },
<       "branches": {
<         "europe": {
<           "primary": {
<             "city": "London",
<             "employees": 250,
<             "opened": "2020-01-15"
<           },
<           "secondary": {
<             "city": "Berlin",
<             "employees": 120,
<             "opened": "2021-03-01"
<           }
<         },
<         "asia": {
<           "primary": {
<             "city": "Tokyo",
<             "employees": 180,
<             "opened": "2019-11-30"
<           }
<         }
<       }
<     },
<     "metrics": {
<       "financial": {
<         "revenue": {
<           "2021": 1500000,
<           "2022": 2200000,
<           "2023": 3100000
<         },
<         "expenses": {
<           "2021": 1200000,
<           "2022": 1800000,
<           "2023": 2500000
<         }
<       },
<       "performance": {
<         "goals": {
<           "q1": 85,
<           "q2": 90,
<           "q3": 88,
<           "q4": 92
<         }
<       }
<     }
<   }
< }
---
> company.details.name=TechCorp
> company.details.founded=1995
> company.details.isPublic=true
> company.locations.headquarters.address.street=123 Innovation Way
> company.locations.headquarters.address.unit=4B
> company.locations.headquarters.address.city=San Francisco
> company.locations.headquarters.address.state=CA
> company.locations.headquarters.address.zip=94105
> company.locations.headquarters.coordinates.lat=37.7749
> company.locations.headquarters.coordinates.lng=-122.4194
> company.locations.branches.europe.primary.city=London
> company.locations.branches.europe.primary.employees=250
> company.locations.branches.europe.primary.opened=2020-01-15
> company.locations.branches.europe.secondary.city=Berlin
> company.locations.branches.europe.secondary.employees=120
> company.locations.branches.europe.secondary.opened=2021-03-01
> company.locations.branches.asia.primary.city=Tokyo
> company.locations.branches.asia.primary.employees=180
> company.locations.branches.asia.primary.opened=2019-11-30
> company.metrics.financial.revenue.2021=1500000
> company.metrics.financial.revenue.2022=2200000
> company.metrics.financial.revenue.2023=3100000
> company.metrics.financial.expenses.2021=1200000
> company.metrics.financial.expenses.2022=1800000
> company.metrics.financial.expenses.2023=2500000
> company.metrics.performance.goals.q1=85
> company.metrics.performance.goals.q2=90
> company.metrics.performance.goals.q3=88
> company.metrics.performance.goals.q4=92

Solutions

The best way to learn is to practice. Below, you will find some of the solutions other golfers have entered. To unlock higher ranked solutions, submit your own entry which does as well or better than the solutions you can currently see - climb the ladder!

Check out these helpful resources to improve your Vim skills... Game on.

Unlock 8 remaining solutions by signing in and submitting your own entry
#9 Lily / @totallyuniquelily - Score: 144 - 11/21/24 @ 05:45
:s/"//g<Home>%<CR>Gddggddqq/{<CR>bbyeviBq<Esc><Esc><Esc>ggjllkbyejqa$F:bi.<Esc>Pquukqq/{<CR>bbyeviB:norm @a<CR><C-O>$%dd<C-O>ddq@q@q@q@q@q@q@q@q22@qgg<G<G<G:s/,//<Home>%<CR>:%s/:/=<CR>:%s/= /=/<CR>ZZ

0 comments


Created by: @pacuna

9 active golfers, 16 entries

Leaderboard (lowest score wins):
44
#1 - Danilo J. S. Bellini 🥊🇧🇷 / @danilobellini

11/10/2024 at 12:22AM

44
#2 - Peppa Pig / @PeppaPi95550250

11/10/2024 at 04:04AM

56
#3 - Christensen, Scott (S.C.) / @MCHRI120_ford

11/04/2024 at 03:29PM

67
#4 - Saurav / @epicblueprints

11/09/2024 at 03:26PM

68
#5 - ehre9305 / @ehre9305

11/02/2024 at 12:47AM

71
#6 - Oleksii Sanin / @AlexSanin

11/17/2024 at 11:26PM

72
#7 - M S Dheeraj Murthy / @Dheeraj-Murthy

11/11/2024 at 10:49AM

99
#8 - cr100 / @rekicc

11/06/2024 at 11:11AM

144
#9 - Lily / @totallyuniquelily

11/21/2024 at 05:45AM