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 4d1ac1800a045132c0000011

Reformat a C golf submission

Take this C golf submission (for the "tiny but standards-compliant Hello World program" category, naturally), and turn it into formatted C code.

Start file
#include<stdio.h>
int main(void){puts("Hello world!");return 0;}
End file
#include <stdio.h>

int main(void)
{
    puts
("Hello world!");
   
return 0;
}

View Diff

--- hw.c        2010-12-28 21:01:54.000000000 -0800
+++ hw-indented.c       2010-12-28 21:04:56.000000000 -0800
@@ -1,2 +1,7 @@
-#include<stdio.h>
-int main(void){puts("Hello world!");return 0;}
+#include <stdio.h>
+
+int main(void)
+{
+    puts("Hello world!");
+    return 0;
+}

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 208 remaining solutions by signing in and submitting your own entry
#209 Frank Hui / @frankhui - Score: 126 - 12/29/10 @ 06:39
:1,$ s/{/{\t/g<CR>:1,$ s/;/;\r\t/g<CR>:1,$ s/>\n/>\r\r/<CR>:1,$ s/{/\r{\r/<CR>:1,$ s/}/\r}\r/<CR><Esc>ddkddkk:1,$ s/\t/    /g<CR>:1,$ s/</ </<CR>:w<CR>:q<CR>

0 comments


Created by: @josh_triplett

209 active golfers, 612 entries

Leaderboard (lowest score wins):
26
#31 - vg / @vimgolfer

02/26/2011 at 12:58PM

26
#32 - Justin Love / @wondible

06/13/2011 at 12:54AM

26
#33 - Junfeng / @junfeng

07/17/2011 at 11:50AM

26
#34 - Andrey Ivanov / @Bytamine

08/11/2011 at 10:45AM

26
#35 - p0ckets / @p0ckets

10/07/2011 at 09:23PM

26
#36 - William Dunand / @wdunand

12/05/2011 at 04:00AM

26
#37 - Zeh Rizzatti / @zehrizzatti

02/08/2012 at 04:46AM

26
#38 - Rod Knowlton / @codelahoma

05/27/2012 at 03:32AM

26
#39 - Chris Brown / @engineercyb

07/13/2012 at 04:36PM

26
#40 - Kerson Hsiao / @KersonHsiao

08/10/2012 at 09:47AM

26
#41 - Jon Krause / @jkrause314

11/20/2015 at 07:45AM

27
#42 - Wei Dai / @clvv42

12/29/2010 at 08:46AM

27
#43 - kana / @kana1

12/29/2010 at 11:24AM

27
#44 - Austin Taylor / @austintaylor

12/29/2010 at 05:04PM

27
#45 - Adam Pohorecki / @apohorecki

12/29/2010 at 11:00PM

27
#46 - AD / @golferTest101

01/01/2011 at 05:14PM

27
#47 - Asmund / @herrasbe

01/02/2011 at 06:49AM

27
#48 - Emile Swarts / @EmileSwarts

06/19/2011 at 04:55PM

27
#49 - Jason Then / @racc69

08/09/2011 at 10:44PM

27
#50 - Tesnorth / @Tesnorth

01/30/2012 at 10:16PM

27
#51 - Fake Name / @The_Real_User

01/10/2014 at 03:39AM

27
#52 - Joonas Pihlajamaa / @jokkebk

02/20/2014 at 10:05PM

28
#53 - Abhishek Mukherjee / @abhishekmukherg

12/29/2010 at 04:16PM

28
#54 - Pete Johns / @johnsyweb

01/10/2011 at 05:22PM

28
#55 - Tim Chase / @gumnos

01/13/2011 at 03:12AM

28
#56 - Rob Ciaccio / @RobertoCalavera

01/23/2011 at 08:21AM

28
#57 - Eivind Jahren / @HaskellElephant

03/28/2011 at 10:07AM

28
#58 - Xavier Nayrac / @lkdjiin

12/30/2011 at 08:28AM

28
#59 - Conner McDaniel / @connermcd

09/19/2012 at 01:56AM

28
#60 - Marcin Szamotulski / @me_coot

11/26/2012 at 09:23AM