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

193 active golfers, 522 entries

Leaderboard (lowest score wins):
26
#31 - Rod Knowlton / @codelahoma

05/27/2012 at 03:32AM

26
#32 - Chris Brown / @engineercyb

07/13/2012 at 04:36PM

26
#33 - Kerson Hsiao / @KersonHsiao

08/10/2012 at 09:47AM

26
#34 - Jon Krause / @jkrause314

11/20/2015 at 07:45AM

27
#35 - Wei Dai / @clvv42

12/29/2010 at 08:46AM

27
#36 - kana / @kana1

12/29/2010 at 11:24AM

27
#37 - Austin Taylor / @austintaylor

12/29/2010 at 05:04PM

27
#38 - Adam Pohorecki / @apohorecki

12/29/2010 at 11:00PM

27
#39 - AD / @golferTest101

01/01/2011 at 05:14PM

27
#40 - Asmund / @herrasbe

01/02/2011 at 06:49AM

27
#41 - Emile Swarts / @EmileSwarts

06/19/2011 at 04:55PM

27
#42 - Jason Then / @racc69

08/09/2011 at 10:44PM

27
#43 - Tesnorth / @Tesnorth

01/30/2012 at 10:16PM

27
#44 - Fake Name / @The_Real_User

01/10/2014 at 03:39AM

27
#45 - Joonas Pihlajamaa / @jokkebk

02/20/2014 at 10:05PM

28
#46 - Abhishek Mukherjee / @abhishekmukherg

12/29/2010 at 04:16PM

28
#47 - Pete Johns / @johnsyweb

01/10/2011 at 05:22PM

28
#48 - Tim Chase / @gumnos

01/13/2011 at 03:12AM

28
#49 - Rob Ciaccio / @RobertoCalavera

01/23/2011 at 08:21AM

28
#50 - Eivind Jahren / @HaskellElephant

03/28/2011 at 10:07AM

28
#51 - Xavier Nayrac / @lkdjiin

12/30/2011 at 08:28AM

28
#52 - Conner McDaniel / @connermcd

09/19/2012 at 01:56AM

28
#53 - Marcin Szamotulski / @me_coot

11/26/2012 at 09:23AM

28
#54 - Nick Bakkegaard / @Bakkemand

11/26/2012 at 10:38PM

28
#55 - Quota / @Quotad

01/29/2014 at 02:45PM

28
#56 - ryk / @rykarn

03/29/2014 at 02:11PM

28
#57 - Skúli Jóhannsson / @skulibj

06/28/2015 at 07:56PM

28
#58 - tPenguinLTG / @tpenguinltg

05/01/2016 at 08:37PM

28
#59 - Curt Matz / @sitrucz

02/09/2017 at 04:27PM

28
#60 - Michał / @Micha46184564

11/14/2020 at 02:56PM