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

190 active golfers, 807 entries

Leaderboard (lowest score wins):
27
#151 - Conor Flynn / @conor-f

08/27/2024 at 09:00AM

27
#152 - Elijah Smith / @theincompletedetective

09/02/2024 at 08:07PM

28
#153 - Fionn Fitzmaurice / @fionn

08/29/2024 at 06:26PM

28
#154 - Tad McCorkle / @tadmccorkle

05/08/2025 at 02:09AM

28
#155 - Stefano Bertoli / @elkiwy

02/09/2026 at 09:51AM

29
#156 - Stanley F / @sfo

07/30/2024 at 07:12AM

30
#157 - Taky0nDon / @Taky0nDon

07/19/2024 at 04:23AM

30
#158 - damned-me / @damned-me

08/15/2024 at 08:45PM

30
#159 - Pablo Acuna / @pacuna

08/27/2024 at 10:49PM

31
#160 - estoneman / @estoneman

05/18/2025 at 11:21PM

31
#161 - Dani Bengl / @cb341

12/22/2025 at 10:12PM

32
#162 - RaBot / @realRaBot

07/23/2024 at 07:45PM

32
#163 - oldtime / @oldtime2021

07/25/2024 at 06:37AM

33
#164 - mirroris / @mirroris

12/17/2024 at 05:13AM

34
#165 - cyan12green / @cyan12green

02/20/2026 at 06:54AM

35
#166 - Vitaly Rudenko / @vitaly-rudenko

08/03/2024 at 10:27AM

35
#167 - Daniel Apt / @DanielApt

08/09/2024 at 03:29PM

35
#168 - DarChan / @richvote

08/12/2024 at 12:29PM

39
#169 - PhinJ / @PhinJ

02/07/2025 at 06:57PM

50
#170 - Michael / @thscuriousquest

08/04/2024 at 06:08PM

50
#171 - Brian Curless / @bwcurless

02/12/2025 at 07:03PM

51
#172 - Karen Mkrtumyan / @KARM99

08/31/2024 at 04:59PM

52
#173 - Sam Zabaldo / @szabaldo

08/08/2024 at 02:50AM

52
#174 - Thoro-las / @Thoro-las

04/05/2025 at 09:17PM

52
#175 - Trent Watson / @trentwatt

09/16/2025 at 06:38AM

54
#176 - Th0ught09 / @Th0ught09

09/22/2024 at 10:08AM

56
#177 - Irakli Chkhetiaini / @chkhetiani

08/15/2024 at 02:26PM

57
#178 - Álvaro Silva / @ricostynha1

07/29/2024 at 09:35PM

63
#179 - CicadaCinema / @CicadaCinema

06/23/2025 at 05:16PM

69
#180 - Raphael Gaschignard / @rtpg

06/27/2025 at 01:09AM