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 171 remaining solutions by signing in and submitting your own entry
#172 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

172 active golfers, 717 entries

Leaderboard (lowest score wins):
18
#61 - KNAKAJIMA2 / @KNAKAJIMA2

03/23/2025 at 01:16AM

19
#62 - HAYASHI-Masayuki / @HAYASHI-Masayuki

07/27/2024 at 10:34AM

19
#63 - Jin Hao / @hongjinhao

07/30/2024 at 08:31AM

19
#64 - michirakara / @michirakara

08/02/2024 at 01:19AM

19
#65 - lc-hanxi / @lc-hanxi

08/08/2024 at 03:37PM

19
#66 - Eric Söderström / @eksoderstrom

08/15/2024 at 12:02AM

19
#67 - gunterkluge / @gunterkluge

08/23/2024 at 02:55PM

19
#68 - Willy / @Willy6932612311

09/03/2024 at 10:51PM

19
#69 - Jason Tucker / @tucker87

09/04/2024 at 05:39AM

19
#70 - rhasarub / @rhasarub

09/05/2024 at 10:13AM

19
#71 - Shoob / @martinshoob

10/17/2024 at 08:41AM

19
#72 - dyedquartz / @dyedquartz

05/13/2025 at 08:54PM

20
#73 - Giacomo Sansone / @pcineverdies

07/14/2024 at 08:47PM

20
#74 - George Duffett / @g-duff

07/16/2024 at 11:02PM

20
#75 - Laurent / @Intuite_in_Twit

07/19/2024 at 02:36AM

20
#76 - evixenon / @evixenon

07/20/2024 at 04:24PM

20
#77 - amberg12 / @amberg12

08/02/2024 at 07:35PM

20
#78 - Håkon Anders Strømsodd / @haakon8855

08/05/2024 at 01:42PM

20
#79 - Skewcy / @ChuanyuXue

08/08/2024 at 03:41PM

20
#80 - whisperbeam / @whisperbeam

08/09/2024 at 10:10PM

20
#81 - VKWHM / @VKWHM

08/12/2024 at 05:30PM

20
#82 - Abhinav D. / @decisivedevops

08/17/2024 at 06:52AM

20
#83 - Viktor Milosavljevic / @NoncommissionedRush

08/18/2024 at 02:57PM

20
#84 - David Wales / @daviewales

08/24/2024 at 11:46AM

20
#85 - Stoyan Dimov / @stoyandimov

09/03/2024 at 07:51AM

20
#86 - Janusz Spatz / @janusz-anue

09/12/2024 at 02:01PM

20
#87 - Anton Strand / @AntonStrand

10/31/2024 at 08:57AM

20
#88 - SnakitoGamer4160 / @SnakitoGamer4160

11/08/2024 at 09:52PM

20
#89 - Swaraj Dash / @swarajdash

12/25/2024 at 01:09PM

20
#90 - Frédéric Heulin / @talineo

12/29/2024 at 11:34PM