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 9v006694339a0000000002e2

Rearrange array to one line

Rearrange the array content on only one line, and remove trailing commas

Start file
const data = [
  {
    goal: 400,
  },
  {
    goal: 300,
  },
  {
    goal: 200,
  },
  {
    goal: 300,
  },
  {
    goal: 200,
  },
  {
    goal: 278,
  },
  {
    goal: 189,
  },
  {
    goal: 239,
  },
  {
    goal: 300,
  },
  {
    goal: 200,
  },
  {
    goal: 278,
  },
  {
    goal: 189,
  },
  {
    goal: 349,
  },
]
End file
const data = [
  { goal: 400 }, { goal: 300 }, { goal: 200 }, { goal: 300 }, { goal: 200 }, { goal: 278 }, { goal: 189 }, { goal: 239 }, { goal: 300 }, { goal: 200 }, { goal: 278 }, { goal: 189 }, { goal: 349 }
]

View Diff

2,40c2
<   {
<     goal: 400,
<   },
<   {
<     goal: 300,
<   },
<   {
<     goal: 200,
<   },
<   {
<     goal: 300,
<   },
<   {
<     goal: 200,
<   },
<   {
<     goal: 278,
<   },
<   {
<     goal: 189,
<   },
<   {
<     goal: 239,
<   },
<   {
<     goal: 300,
<   },
<   {
<     goal: 200,
<   },
<   {
<     goal: 278,
<   },
<   {
<     goal: 189,
<   },
<   {
<     goal: 349,
<   },
---
>   { goal: 400 }, { goal: 300 }, { goal: 200 }, { goal: 300 }, { goal: 200 }, { goal: 278 }, { goal: 189 }, { goal: 239 }, { goal: 300 }, { goal: 200 }, { goal: 278 }, { goal: 189 }, { goal: 349 }

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 198 remaining solutions by signing in and submitting your own entry
#199 Driftingdrifting / @Driftingdrifting - Score: 232 - 07/16/24 @ 16:45
:%s/{\n^\w<Left><Left><Left>\<BS>\[<Right><Right><Right>]<Tab><BS>*\(\w)<BS><BS><BS>goal"<BS>: []<Left>0-9<Right>*\),\n.*/\1/g<CR>/{\n[]<Left>.<BS> <BS>^\w<Right>*<BS><BS><BS><BS>a-<BS><BS>g]*(^,)<Left><Left><Left><Left>\<Right><Right><Right>\<Right><BS><BS><BS><BS><BS><BS>\([^,]*\),\n.*/{ \1 },/g<Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><BS><CR><Esc>:%d<BS>s/<50-53>{\n[^g]*\([^,]*\),\n.*/{ \1 },/g <Esc>[201~<CR>2GV14<CR><Up>J$x:wq<CR>

0 comments


Created by: @alexandregv

199 active golfers, 852 entries

Leaderboard (lowest score wins):
13
#31 - kloir-z / @kloir-z

01/24/2026 at 11:07AM

13
#32 - Alastair / @alastairsounds

04/08/2026 at 08:52PM

13
#33 - aaay-aaay / @aaay-aaay

04/09/2026 at 09:46PM

13
#34 - 000AG000 / @000AG000

05/07/2026 at 07:02PM

14
#35 - Sandeep Dhavale / @sandeep_dhavale

07/26/2024 at 10:21PM

14
#36 - Roger Stoltz / @rogsto1

08/15/2024 at 02:52PM

14
#37 - Someone / @inventfossil

08/17/2024 at 07:14PM

14
#38 - shenyfg / @shenyfg

08/29/2024 at 06:29AM

14
#39 - Henry Sloan / @HenryKSloan

09/01/2024 at 11:19PM

14
#40 - Marek Skrobacki / @skrobul

09/14/2024 at 10:27PM

14
#41 - MatFriend / @MatFriend

09/24/2024 at 06:21AM

14
#42 - elforeee / @elforeee

09/30/2024 at 11:22AM

14
#43 - rasputins / @rasputins

10/23/2024 at 05:39AM

14
#44 - ahenches / @ahenches

02/22/2025 at 12:41PM

14
#45 - Zsanett Ferenczi / @ferenczizsani

04/24/2025 at 05:09PM

14
#46 - jimmymills / @jimmymills

05/16/2025 at 01:12AM

14
#47 - Berel94 / @Berel94

09/24/2025 at 10:08AM

15
#48 - Valacar / @valacar

07/16/2024 at 05:53PM

15
#49 - Marcos Almeida / @maurelio1234

07/16/2024 at 10:47PM

15
#50 - Brian Greenhill / @BrianGreenhill

07/16/2024 at 11:35PM

15
#51 - Alex / @alexmatthaios

07/19/2024 at 09:51PM

15
#52 - Petter Hoem Sletsjøe / @petterhs

08/06/2024 at 12:29PM

15
#53 - tobi256 / @tobi256

08/21/2024 at 10:24PM

15
#54 - ばやし / @shin5884_kt

09/15/2024 at 08:40AM

15
#55 - DayuanX / @DayuanX

10/24/2024 at 07:58AM

15
#56 - Nathan Priego / @nspriego

02/22/2025 at 10:44PM

16
#57 - Archar Gelod / @Archargelod

07/16/2024 at 04:32PM

16
#58 - Ben Gadbois / @bengadbois

08/08/2024 at 09:03PM

16
#59 - Henrik Lehtonen / @helehto

08/17/2024 at 10:54PM

16
#60 - Ariel Buchwald-Kearney / @arielbk

08/19/2024 at 06:17AM