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):
13
#1 - Peppa Pig / @PeppaPigSg

07/15/2024 at 01:41AM

13
#2 - Pablo Cárdenas / @pablo_cardenasb

07/16/2024 at 09:52AM

13
#3 - Petro Тrouq / @zulolosi

07/16/2024 at 10:46AM

13
#4 - Vic Segers / @VicSegers

07/17/2024 at 02:26PM

13
#5 - Danilo J. S. Bellini 🥊🇧🇷 / @danilobellini

07/18/2024 at 03:10AM

13
#6 - Blake Raymond / @bit-ray

07/19/2024 at 06:18AM

13
#7 - John Braxler / @braxler

07/22/2024 at 01:00PM

13
#8 - Alex Lewin / @_AlexLewin

07/23/2024 at 10:01PM

13
#9 - Nerdeose / @Nerdeose

07/25/2024 at 12:29PM

13
#10 - Bart Hageman / @BartHageman

08/12/2024 at 03:49PM

13
#11 - RZMNR / @RZMNR

08/14/2024 at 04:39PM

13
#12 - nickGPT / @nickandbro

08/20/2024 at 08:00AM

13
#13 - Karim / @KarimIbrahim

08/22/2024 at 04:51AM

13
#14 - Suhaib Murshid / @suhaibm

08/24/2024 at 06:19AM

13
#15 - Anton / @Sobes76rus

08/25/2024 at 11:43PM

13
#16 - AMD_RYZEN_5_9600X / @amdRyzen5600X

09/03/2024 at 11:00AM

13
#17 - ARK / @ARezaK

09/12/2024 at 06:54PM

13
#18 - Brett Collins / @brett-collins_cbhq

10/02/2024 at 05:42PM

13
#19 - got_windy / @insomnight

10/24/2024 at 06:35AM

13
#20 - mtklar / @mtklar

10/25/2024 at 07:37AM

13
#21 - countime / @countime

12/02/2024 at 07:13AM

14
#22 - Sandeep Dhavale / @sandeep_dhavale

07/26/2024 at 10:21PM

14
#23 - Roger Stoltz / @rogsto1

08/15/2024 at 02:52PM

14
#24 - Someone / @inventfossil

08/17/2024 at 07:14PM

14
#25 - shenyfg / @shenyfg

08/29/2024 at 06:29AM

14
#26 - Henry Sloan / @HenryKSloan

09/01/2024 at 11:19PM

14
#27 - Marek Skrobacki / @skrobul

09/14/2024 at 10:27PM

14
#28 - MatFriend / @MatFriend

09/24/2024 at 06:21AM

14
#29 - elforeee / @elforeee

09/30/2024 at 11:22AM

14
#30 - rasputins / @rasputins

10/23/2024 at 05:39AM