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 by @sagesancast:

Unlock 1 remaining solutions by signing in and submitting your own entry
Created by: @fohte

20 active golfers, 49 entries

Solutions by @sagesancast:
62
#18 - Sage san / @sagesancast

12/20/2017 at 02:19PM