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

187 active golfers, 799 entries

Leaderboard (lowest score wins):
20
#91 - Viktor Milosavljevic / @NoncommissionedRush

08/18/2024 at 02:57PM

20
#92 - David Wales / @daviewales

08/24/2024 at 11:46AM

20
#93 - Stoyan Dimov / @stoyandimov

09/03/2024 at 07:51AM

20
#94 - Janusz Spatz / @janusz-anue

09/12/2024 at 02:01PM

20
#95 - Anton Strand / @AntonStrand

10/31/2024 at 08:57AM

20
#96 - Snak / @ssnak

11/08/2024 at 09:52PM

20
#97 - Swaraj Dash / @swarajdash

12/25/2024 at 01:09PM

20
#98 - Frédéric Heulin / @talineo

12/29/2024 at 11:34PM

20
#99 - hwatson381 / @hwatson381

04/30/2025 at 12:20PM

20
#100 - Rafe Murray / @rafe-murray

01/17/2026 at 05:41AM

21
#101 - Andreas Kruck / @Spanching

07/16/2024 at 04:26PM

21
#102 - Namdrib / @Namdrib

07/21/2024 at 11:40AM

21
#103 - gnragazzi / @gnragazzi

07/28/2024 at 11:57PM

21
#104 - C. Koch / @ckob

07/29/2024 at 03:45PM

21
#105 - ruxandrastancioi / @ruxandrastancioi

07/31/2024 at 01:57PM

21
#106 - Rodi-Janssen / @Rodi-Janssen

07/31/2024 at 08:07PM

21
#107 - Farouq Aldori / @farouqaldori

08/05/2024 at 07:54PM

21
#108 - Hector Bjernersjö / @HectorBjernersjo

08/15/2024 at 05:13PM

21
#109 - Alex Khakhlyuk / @khakhlyuk

08/21/2024 at 02:26PM

21
#110 - sammy-kablammy / @sammy-kablammy

08/24/2024 at 09:48PM

21
#111 - Frank Rogalski / @FrankRogalski

08/25/2024 at 05:00PM

21
#112 - pizzaburgare / @pizzaburgare

10/22/2024 at 11:13AM

21
#113 - Brice Bischoff / @B-Bischoff

10/25/2024 at 08:42AM

21
#114 - Jorge Nonell / @JorgeNonel56315

01/17/2025 at 04:15PM

22
#115 - Felix / @ne0phyte

07/17/2024 at 05:49PM

22
#116 - Kevin Lou / @klou23

07/26/2024 at 04:51PM

22
#117 - James Skinner / @JSkinnerUK

08/09/2024 at 02:51PM

22
#118 - mgn1440 / @mgn1440

08/14/2024 at 02:39PM

22
#119 - Felix Pankratz / @panki27

08/29/2024 at 01:58PM

22
#120 - ak@developer / @Ajay-056

09/08/2024 at 03:55PM