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):
21
#121 - Jorge Nonell / @JorgeNonel56315

01/17/2025 at 04:15PM

22
#122 - Felix / @ne0phyte

07/17/2024 at 05:49PM

22
#123 - Kevin Lou / @klou23

07/26/2024 at 04:51PM

22
#124 - James Skinner / @JSkinnerUK

08/09/2024 at 02:51PM

22
#125 - mgn1440 / @mgn1440

08/14/2024 at 02:39PM

22
#126 - Felix Pankratz / @panki27

08/29/2024 at 01:58PM

22
#127 - ak@developer / @Ajay-056

09/08/2024 at 03:55PM

22
#128 - Adi / @adi2004

05/02/2025 at 09:44AM

22
#129 - Martin Knoller Stocker / @linuxswords

07/10/2025 at 03:36PM

22
#130 - kettlemaster / @kettlemaster

07/27/2025 at 07:47PM

22
#131 - phaym / @phaym

10/12/2025 at 08:28PM

22
#132 - michaelgattas / @michaelgattas

05/08/2026 at 05:50PM

23
#133 - sg-hk / @sg-hk

08/17/2024 at 08:01AM

23
#134 - Christopher Wood / @CWood-sdf

08/29/2024 at 10:07PM

23
#135 - Sebastian Mellor (Jumping Rivers) / @sjimellor-jr

09/11/2024 at 11:18AM

23
#136 - luke37842 / @luke37842

11/05/2024 at 05:37PM

24
#137 - Alex Elarbee / @elarbee

09/21/2024 at 12:27PM

24
#138 - fenec / @fenec

09/21/2024 at 05:32PM

25
#139 - John / @john_burner_1

08/06/2024 at 01:42PM

25
#140 - NotWearingPants / @NotWearingPants

08/06/2024 at 11:50PM

25
#141 - Serj S. / @ar0ne

08/15/2024 at 07:37PM

25
#142 - Askma milk / @AskmaMilk55085

08/18/2024 at 01:47AM

25
#143 - CleisthenesH / @CleisthenesH

08/19/2024 at 11:01AM

25
#144 - Xiaoshubudao / @XiaoshuZ73684

08/19/2024 at 10:22PM

25
#145 - danielbonkowsky / @danielbonkowsky

08/23/2024 at 07:06PM

25
#146 - BrandonChenZT / @BrandonChenZT

10/26/2024 at 09:03AM

26
#147 - djheidihoe / @djheidihoe1

07/22/2024 at 09:23PM

26
#148 - Antonio Cormoranes / @anonymous_joe

07/24/2024 at 09:19PM

26
#149 - Roland Hollós / @hollorol

07/29/2024 at 10:53AM

26
#150 - Sean Williams / @SeanThomasWilliams

08/13/2024 at 02:23PM