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

170 active golfers, 707 entries

Leaderboard (lowest score wins):
25
#121 - Askma milk / @AskmaMilk55085

08/18/2024 at 01:47AM

25
#122 - CleisthenesH / @CleisthenesH

08/19/2024 at 11:01AM

25
#123 - Xiaoshubudao / @XiaoshuZ73684

08/19/2024 at 10:22PM

25
#124 - danielbonkowsky / @danielbonkowsky

08/23/2024 at 07:06PM

25
#125 - BrandonChenZT / @BrandonChenZT

10/26/2024 at 09:03AM

26
#126 - djheidihoe / @djheidihoe1

07/22/2024 at 09:23PM

26
#127 - Antonio Cormoranes / @anonymous_joe

07/24/2024 at 09:19PM

26
#128 - Roland Hollós / @hollorol

07/29/2024 at 10:53AM

26
#129 - Sean Williams / @SeanThomasWilliams

08/13/2024 at 02:23PM

26
#130 - George Granberry / @ggranberry

08/16/2024 at 07:57PM

26
#131 - Jonathan Schaaij / @jonathanschaaij

08/21/2024 at 06:50PM

26
#132 - Fabrice Tsiava / @FabriceTsiava

09/19/2024 at 06:39AM

27
#133 - Alexandre GV. / @alexandregv

07/14/2024 at 08:35PM

27
#134 - Murphy / @TemplateXu

08/19/2024 at 05:23AM

27
#135 - Diwakar Singh Parmar / @parmardiwakar150

08/25/2024 at 03:35PM

27
#136 - Tarin Mahmood / @tmahmood

08/27/2024 at 01:12AM

27
#137 - Conor Flynn / @conor-f

08/27/2024 at 09:00AM

27
#138 - Elijah Smith / @theincompletedetective

09/02/2024 at 08:07PM

28
#139 - Fionn Fitzmaurice / @fionn

08/29/2024 at 06:26PM

28
#140 - Tad McCorkle / @tadmccorkle

05/08/2025 at 02:09AM

29
#141 - Stanley F / @sfo

07/30/2024 at 07:12AM

30
#142 - Taky0nDon / @Taky0nDon

07/19/2024 at 04:23AM

30
#143 - damned-me / @damned-me

08/15/2024 at 08:45PM

30
#144 - Pablo Acuna / @pacuna

08/27/2024 at 10:49PM

31
#145 - estoneman / @estoneman

05/18/2025 at 11:21PM

32
#146 - RaBot / @realRaBot

07/23/2024 at 07:45PM

32
#147 - oldtime / @oldtime2021

07/25/2024 at 06:37AM

33
#148 - mirroris / @mirroris

12/17/2024 at 05:13AM

35
#149 - Vitaly Rudenko / @vitaly-rudenko

08/03/2024 at 10:27AM

35
#150 - Daniel Apt / @DanielApt

08/09/2024 at 03:29PM