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

140 active golfers, 576 entries

Leaderboard (lowest score wins):
22
#91 - ak@developer / @Ajay-056

09/08/2024 at 03:55PM

23
#92 - sg-hk / @sg-hk

08/17/2024 at 08:01AM

23
#93 - Christopher Wood / @CWood-sdf

08/29/2024 at 10:07PM

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

09/11/2024 at 11:18AM

24
#95 - Alex Elarbee / @elarbee

09/21/2024 at 12:27PM

24
#96 - fenec / @fenec

09/21/2024 at 05:32PM

25
#97 - John / @john_burner_1

08/06/2024 at 01:42PM

25
#98 - NotWearingPants / @NotWearingPants

08/06/2024 at 11:50PM

25
#99 - Serj S. / @ar0ne

08/15/2024 at 07:37PM

25
#100 - Askma milk / @AskmaMilk55085

08/18/2024 at 01:47AM

25
#101 - CleisthenesH / @CleisthenesH

08/19/2024 at 11:01AM

25
#102 - Xiaoshubudao / @XiaoshuZ73684

08/19/2024 at 10:22PM

25
#103 - danielbonkowsky / @danielbonkowsky

08/23/2024 at 07:06PM

25
#104 - BrandonChenZT / @BrandonChenZT

10/26/2024 at 09:03AM

25
#105 - Pim / @Pireax

11/02/2024 at 01:10PM

26
#106 - djheidihoe / @djheidihoe1

07/22/2024 at 09:23PM

26
#107 - Antonio Cormoranes / @anonymous_joe

07/24/2024 at 09:19PM

26
#108 - Roland Hollós / @hollorol

07/29/2024 at 10:53AM

26
#109 - Sean Williams / @SeanThomasWilliams

08/13/2024 at 02:23PM

26
#110 - George Granberry / @ggranberry

08/16/2024 at 07:57PM

26
#111 - Jonathan Schaaij / @jonathanschaaij

08/21/2024 at 06:50PM

26
#112 - Fabrice Tsiava / @FabriceTsiava

09/19/2024 at 06:39AM

27
#113 - Alexandre GV. / @alexandregv

07/14/2024 at 08:35PM

27
#114 - Murphy / @TemplateXu

08/19/2024 at 05:23AM

27
#115 - Diwakar Singh Parmar / @parmardiwakar150

08/25/2024 at 03:35PM

27
#116 - Tarin Mahmood / @tmahmood

08/27/2024 at 01:12AM

27
#117 - Conor Flynn / @conor-f

08/27/2024 at 09:00AM

27
#118 - Elijah Smith / @theincompletedetective

09/02/2024 at 08:07PM

28
#119 - Fionn Fitzmaurice / @fionn

08/29/2024 at 06:26PM

29
#120 - Stanley F / @sfo

07/30/2024 at 07:12AM