The more you know, the more you see.
- Aldous Huxley
Vim, the legendary text editor, has always fascinated me. I distinctly remember 'Mastering the Vim Language' talk by Chris Toomey being the one that hooked me onto Vim. Chris's first slide reads "I love Vim because I've yet to hit the ceiling" and it perfectly captures Vim's fandom (there's the hate side as well). I have been using Vim for years now, and for the quest for mastery, I often visit VimGolf - like in golf where the lowest score wins, it's a platform where Vim enthusiasts solve text editing challenges aiming for the minimum number of keystrokes.
Recently, I encountered a challenge that caught my attention: transform a deeply nested JSON structure into a flattened key-value format using dot notation. You know what's ironic? Even the most ardent Vim users would reach for Python's json library or jq or some online JSON transformer when facing such a task in real work. Yet here I was, staring at a problem that basically asked: can you turn {"company": {"name": "TechCorp"}}
into company.name=TechCorp
using just Vim commands?
The nested structure made it particularly tricky. I gave up quite early and decided to look at one of the accepted solutions (VimGolf only lets you peek at solutions that are just above yours on the leaderboard). What I saw was both impressive and bewildering - a sequence of keystrokes that solved the problem in 99 characters (at the time of writing, lowest score stood at 46!). But understanding how it worked? I knew Vim well but decoding this gibberish seemed like a very tedious task.
cr100's 99 keystrokes solution:
qq/{<CR>0yi"$maV%:s/"/<C-R>"."<CR>`a$%dd`a.q22@qddGdd:normal +<BS>=<CR>:%normal +<BS>=<CR>gg=G:%s/[",]//g<CR>:s<BS>%s/: /=<CR>:wq<CR>
Then I had an idea. What if I asked a Large Language Model (Claude being my favourite) to explain this solution? More out of curiosity than hope, I presented the keystrokes to Claude and asked for an explanation. What happened next surprised me completely. Claude broke down those 99 cryptic characters into 20 logical, meaningful steps, like a cryptographer decoding a well-crafted cipher. Each step's purpose became clear, and the solution's elegance started to shine through.
Here's how Claude broke it down:
1. `qq` - Start recording a macro into register 'q'
2. `/{<CR>` - Search for next '{' character
3. `0yi"` - Go to start of line (0), yank text inside quotes (yi")
4. `$ma` - Go to end of line ($), set mark 'a' (ma)
5. `V%` - Select current line in visual line mode (V), and match to closing bracket (%)
6. `:s/"/<C-R>"."<CR>` - In the selected range, replace quotes with the previously yanked text followed by a dot
7. ``a` - Jump back to mark 'a'
8. `$%` - Go to end of line ($) and find matching bracket (%)
9. `dd` - Delete the line
10. ``a` - Jump back to mark 'a'
11. `.` - Repeat last change
12. `q` - Stop recording macro
13. `22@q` - Execute macro 'q' 22 times
14. `ddGdd` - Delete current line (dd), go to end of file (G), delete last line (dd)
15. `:normal +<BS>=<CR>` - Run normal mode command to format
16. `:%normal +<BS>=<CR>` - Run normal mode command on all lines
17. `gg=G` - Reindent entire file
18. `:%s/[",]//g<CR>` - Remove all quotes and commas globally
19. `:s%s/: /=<CR>` - Replace ": " with "=" globally
20. `:wq<CR>` - Save and quit
I saw some minor improvements in this approach (15 & 16 not needed, :wq could be replaced with ZZ, ddGdd in 14 could be replaced with ddG., ...) and submitted a slightly improved solution with ~70 keystrokes. Throughout this process, I had several follow-up conversations with Claude - checking file states after every 5 steps, diving deeper into unfamiliar syntax, and getting detailed explanations of complex operations. I've documented my entire conversation with Claude in this doc for those interested in the complete breakdown.
I'm still amazed by what I witnessed, and each day with LLMs brings new surprises. Despite the AI revolution being in full swing since late 2022 (launch of ChatGPT), I only recently started exploring LLMs. This experience with VimGolf showed me something profound - LLMs can bridge the gap between expert knowledge and understanding, breaking down complexity into digestible pieces, turning what looks like arcane knowledge into clear, logical steps. The implications are exciting - could this be the key to lowering entry barriers for complex tools and technologies? For those interested in exploring the world of LLMs, I highly recommend starting with Simon Willison's captivating PyCon US Keynote video. As for me, I can't help but wonder - what other technical mysteries could Claude help me unravel?