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

152 active golfers, 616 entries

Leaderboard (lowest score wins):
15
#31 - Valacar / @valacar

07/16/2024 at 05:53PM

15
#32 - Marcos Almeida / @maurelio1234

07/16/2024 at 10:47PM

15
#33 - Brian Greenhill / @BrianGreenhill

07/16/2024 at 11:35PM

15
#34 - Alex / @alexmatthaios

07/19/2024 at 09:51PM

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

08/06/2024 at 12:29PM

15
#36 - tobi256 / @tobi256

08/21/2024 at 10:24PM

15
#37 - ばやし / @shin5884_kt

09/15/2024 at 08:40AM

15
#38 - DayuanX / @DayuanX

10/24/2024 at 07:58AM

16
#39 - Archar Gelod / @Archargelod

07/16/2024 at 04:32PM

16
#40 - Ben Gadbois / @bengadbois

08/08/2024 at 09:03PM

16
#41 - Henrik Lehtonen / @helehto

08/17/2024 at 10:54PM

16
#42 - Ariel Buchwald-Kearney / @arielbk

08/19/2024 at 06:17AM

16
#43 - Joris / @CheeseAndChips

08/29/2024 at 01:32PM

16
#44 - daniilsvirin / @daniilsvirin

10/14/2024 at 06:23PM

16
#45 - JohanNorberg / @JohanNorberg

01/25/2025 at 10:00PM

16
#46 - Paroxyss / @Paroxyss

02/10/2025 at 12:19PM

17
#47 - Maximilian Ballard / @ediw8311xht

08/05/2024 at 12:57AM

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

08/15/2024 at 05:16PM

17
#49 - Pim / @Pireax

11/08/2024 at 02:24AM

17
#50 - NoponyAsked / @NoponyAsked

02/02/2025 at 11:08AM

18
#51 - MartnRamtin / @MartnRamtin

09/07/2024 at 04:54PM

18
#52 - Neix20 / @Neix20

10/02/2024 at 08:09AM

19
#53 - HAYASHI-Masayuki / @HAYASHI-Masayuki

07/27/2024 at 10:34AM

19
#54 - Jin Hao / @hongjinhao

07/30/2024 at 08:31AM

19
#55 - michirakara / @michirakara

08/02/2024 at 01:19AM

19
#56 - lc-hanxi / @lc-hanxi

08/08/2024 at 03:37PM

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

08/15/2024 at 12:02AM

19
#58 - gunterkluge / @gunterkluge

08/23/2024 at 02:55PM

19
#59 - Willy / @Willy6932612311

09/03/2024 at 10:51PM

19
#60 - Jason Tucker / @tucker87

09/04/2024 at 05:39AM