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 5a390183530db00e38000001

Sort yaml structures alphabetically by root key names

sometimes we want to sort structures alphabetically in yaml files

Start file
c:
  required
: false

h
:
  optional
: true
  choice
:
   
- true
   
- false

f
:
  required
: true

e
:
  optional
: true
  choice
:
   
- b
   
- a

g
:
  optional
: false

j
:
  required
: true

a
:
  required
: true

i
:
  required
: false

d
:
  required
: false

b
:
  optional
: true
  choice
:
   
- 1
   
- 2
End file
a:
  required
: true

b
:
  optional
: true
  choice
:
   
- 1
   
- 2

c
:
  required
: false

d
:
  required
: false

e
:
  optional
: true
  choice
:
   
- b
   
- a

f
:
  required
: true

g
:
  optional
: false

h
:
  optional
: true
  choice
:
   
- true
   
- false

i
:
  required
: false

j
:
  required
: true

View Diff

diff --git a/old.yml b/new.yml
index a925691..a36642f 100644
--- a/old.yml
+++ b/new.yml
@@ -1,14 +1,17 @@
+a:
+  required: true
+
+b:
+  optional: true
+  choice:
+    - 1
+    - 2
+
 c
:
   required
: false
 

-h:
-  optional: true
-  choice:
-    - true
-    - false
-
-f:
-  required: true
+d:
+  required: false
 

 e
:
   optional
: true
@@ -16,23 +19,20 @@ e:
     
- b
     
- a
 

+f:
+  required: true
+
 g
:
   optional
: false
 

-j:
-  required: true
-
-a:
-  required: true
+h:
+  optional: true
+  choice:
+    - true
+    - false
 

 i
:
   required
: false
 

-d:
-  required: false
-
-b:
-  optional: true
-  choice:
-    - 1
-    - 2
+j:
+  required: true

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 19 remaining solutions by signing in and submitting your own entry
#20 Ben Hill / @KaizenSoze70 - Score: 91 - 12/19/17 @ 13:03
34GdGggPjjjjo<Esc>37GdG10GP37GdG19GP37GdGggP37G3<Esc>dGudG25GP37G3<Esc>dG16GP34GdGudG16GP37GdG22GPGddZZ

0 comments


Created by: @fohte

20 active golfers, 49 entries

Leaderboard (lowest score wins):
31
#1 - tPenguinLTG / @tpenguinltg

12/20/2017 at 09:06AM

31
#2 - John Braxler / @braxler

09/19/2019 at 05:39PM

31
#3 - Alex / @AlexanderHeatl2

08/29/2022 at 08:39PM

31
#4 - Luoyb / @Luoyb

11/14/2023 at 09:53AM

31
#5 - Peppa Pig / @PeppaPigSg

07/01/2024 at 01:37AM

31
#6 - nickGPT / @nickandbro

08/27/2024 at 05:17AM

32
#7 - LungZeno / @LungZenoOpen

01/16/2018 at 09:29PM

33
#8 - DHM / @DHM29978992

05/20/2018 at 02:32AM

34
#9 - Jon Krause / @jkrause314

12/25/2017 at 04:05AM

35
#10 - quemeraisc / @quemeraisc

05/16/2022 at 08:31AM

35
#11 - Vgaccount645 / @vgaccount616132

04/15/2023 at 08:36PM

36
#12 - Saki Gw / @Sakigw

12/19/2017 at 01:06PM

44
#13 - Lajos Koszti / @Ajnasz

12/19/2017 at 01:19PM

44
#14 - Elliott Bignell / @ElliottCBi

12/19/2017 at 02:33PM

44
#15 - Klaus-Peter Schreiner / @KlaPeSch13

03/08/2018 at 07:55AM

45
#16 - mnx / @mnxx

01/04/2018 at 10:25AM

57
#17 - c0llision / @sh3llcode

01/27/2018 at 08:22PM

62
#18 - Sage san / @sagesancast

12/20/2017 at 02:19PM

76
#19 - Marc André Freiheit / @marc_freiheit

05/29/2018 at 11:05AM

91
#20 - Ben Hill / @KaizenSoze70

12/19/2017 at 01:03PM