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

174 active golfers, 719 entries

Leaderboard (lowest score wins):
14
#31 - MatFriend / @MatFriend

09/24/2024 at 06:21AM

14
#32 - elforeee / @elforeee

09/30/2024 at 11:22AM

14
#33 - rasputins / @rasputins

10/23/2024 at 05:39AM

14
#34 - ahenches / @ahenches

02/22/2025 at 12:41PM

14
#35 - Zsanett Ferenczi / @ferenczizsani

04/24/2025 at 05:09PM

14
#36 - jimmymills / @jimmymills

05/16/2025 at 01:12AM

15
#37 - Valacar / @valacar

07/16/2024 at 05:53PM

15
#38 - Marcos Almeida / @maurelio1234

07/16/2024 at 10:47PM

15
#39 - Brian Greenhill / @BrianGreenhill

07/16/2024 at 11:35PM

15
#40 - Alex / @alexmatthaios

07/19/2024 at 09:51PM

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

08/06/2024 at 12:29PM

15
#42 - tobi256 / @tobi256

08/21/2024 at 10:24PM

15
#43 - ばやし / @shin5884_kt

09/15/2024 at 08:40AM

15
#44 - DayuanX / @DayuanX

10/24/2024 at 07:58AM

15
#45 - Nathan Priego / @nspriego

02/22/2025 at 10:44PM

16
#46 - Archar Gelod / @Archargelod

07/16/2024 at 04:32PM

16
#47 - Ben Gadbois / @bengadbois

08/08/2024 at 09:03PM

16
#48 - Henrik Lehtonen / @helehto

08/17/2024 at 10:54PM

16
#49 - Ariel Buchwald-Kearney / @arielbk

08/19/2024 at 06:17AM

16
#50 - Joris / @CheeseAndChips

08/29/2024 at 01:32PM

16
#51 - daniilsvirin / @daniilsvirin

10/14/2024 at 06:23PM

16
#52 - JohanNorberg / @JohanNorberg

01/25/2025 at 10:00PM

16
#53 - Paroxyss / @Paroxyss

02/10/2025 at 12:19PM

17
#54 - Maximilian Ballard / @ediw8311xht

08/05/2024 at 12:57AM

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

08/15/2024 at 05:16PM

17
#56 - Pim / @Pireax

11/08/2024 at 02:24AM

17
#57 - NoponyAsked / @NoponyAsked

02/02/2025 at 11:08AM

18
#58 - MartnRamtin / @MartnRamtin

09/07/2024 at 04:54PM

18
#59 - Neix20 / @Neix20

10/02/2024 at 08:09AM

18
#60 - chujDK / @chujDK

03/05/2025 at 09:08AM