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

122 active golfers, 477 entries

Leaderboard (lowest score wins):
16
#31 - Archar Gelod / @Archargelod

07/16/2024 at 04:32PM

16
#32 - Ben Gadbois / @bengadbois

08/08/2024 at 09:03PM

16
#33 - Henrik Lehtonen / @helehto

08/17/2024 at 10:54PM

16
#34 - Ariel Buchwald-Kearney / @arielbk

08/19/2024 at 06:17AM

16
#35 - Joris / @CheeseAndChips

08/29/2024 at 01:32PM

17
#36 - Maximilian Ballard / @ediw8311xht

08/05/2024 at 12:57AM

17
#37 - J̻̕ͅo̠̻̘h̼̖n̙̩̝͕ D̹̗̗͝oe̶̱̥͙ / @JohnJDoe2

08/15/2024 at 05:16PM

18
#38 - MartnRamtin / @MartnRamtin

09/07/2024 at 04:54PM

19
#39 - HAYASHI-Masayuki / @HAYASHI-Masayuki

07/27/2024 at 10:34AM

19
#40 - Jin Hao / @hongjinhao

07/30/2024 at 08:31AM

19
#41 - michirakara / @michirakara

08/02/2024 at 01:19AM

19
#42 - lc-hanxi / @lc-hanxi

08/08/2024 at 03:37PM

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

08/15/2024 at 12:02AM

19
#44 - gunterkluge / @gunterkluge

08/23/2024 at 02:55PM

19
#45 - Willy / @Willy6932612311

09/03/2024 at 10:51PM

19
#46 - Jason Tucker / @tucker87

09/04/2024 at 05:39AM

19
#47 - rhasarub / @rhasarub

09/05/2024 at 10:13AM

20
#48 - Giacomo Sansone / @pcineverdies

07/14/2024 at 08:47PM

20
#49 - George Duffett / @g-duff

07/16/2024 at 11:02PM

20
#50 - Laurent / @Intuite_in_Twit

07/19/2024 at 02:36AM

20
#51 - evixenon / @evixenon

07/20/2024 at 04:24PM

20
#52 - amberg12 / @amberg12

08/02/2024 at 07:35PM

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

08/05/2024 at 01:42PM

20
#54 - Skewcy / @ChuanyuXue

08/08/2024 at 03:41PM

20
#55 - whisperbeam / @whisperbeam

08/09/2024 at 10:10PM

20
#56 - VKWHM / @VKWHM

08/12/2024 at 05:30PM

20
#57 - Abhinav D. / @decisivedevops

08/17/2024 at 06:52AM

20
#58 - Viktor Milosavljevic / @NoncommissionedRush

08/18/2024 at 02:57PM

20
#59 - David Wales / @daviewales

08/24/2024 at 11:46AM

20
#60 - Stoyan Dimov / @stoyandimov

09/03/2024 at 07:51AM