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

142 active golfers, 588 entries

Leaderboard (lowest score wins):
28
#121 - Fionn Fitzmaurice / @fionn

08/29/2024 at 06:26PM

29
#122 - Stanley F / @sfo

07/30/2024 at 07:12AM

30
#123 - Taky0nDon / @Taky0nDon

07/19/2024 at 04:23AM

30
#124 - damned-me / @damned-me

08/15/2024 at 08:45PM

30
#125 - Pablo Acuna / @pacuna

08/27/2024 at 10:49PM

32
#126 - RaBot / @realRaBot

07/23/2024 at 07:45PM

32
#127 - oldtime / @oldtime2021

07/25/2024 at 06:37AM

35
#128 - Vitaly Rudenko / @vitaly-rudenko

08/03/2024 at 10:27AM

35
#129 - Daniel Apt / @DanielApt

08/09/2024 at 03:29PM

35
#130 - DarChan / @richvote

08/12/2024 at 12:29PM

50
#131 - Michael / @thscuriousquest

08/04/2024 at 06:08PM

51
#132 - Karen Mkrtumyan / @KARM99

08/31/2024 at 04:59PM

52
#133 - Sam Zabaldo / @szabaldo

08/08/2024 at 02:50AM

54
#134 - Kirk Matt / @Th0ught09

09/22/2024 at 10:08AM

56
#135 - Irakli Chkhetiaini / @chkhetiani

08/15/2024 at 02:26PM

57
#136 - Álvaro Silva / @ricostynha1

07/29/2024 at 09:35PM

71
#137 - Sylvain Dangin / @Sylvaner

08/03/2024 at 09:36PM

72
#138 - aeha / @aeha_official

08/05/2024 at 11:41AM

80
#139 - LukasOates / @LukasOates

07/18/2024 at 11:53PM

137
#140 - schlottmancole / @schlottmancole

08/04/2024 at 04:15PM

152
#141 - Fredrik Lundström / @Flundrahn

07/31/2024 at 10:51PM

232
#142 - Driftingdrifting / @Driftingdrifting

07/16/2024 at 04:45PM