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):
36
#151 - A. N. / @arez42

10/24/2013 at 04:18PM

36
#152 - Ram Tamtam / @ramtamtamtam

07/02/2014 at 11:56AM

37
#153 -  Ikhsan Maulana / @ixandidu

12/30/2010 at 12:00PM

37
#154 - Dave Bradford / @dbradf

06/17/2011 at 11:23PM

37
#155 - xiaoao1024 / @xiaoao1024

12/28/2023 at 10:28AM

38
#156 - Lance Becker / @lrbecker

12/29/2010 at 05:48AM

38
#157 - Fer Enaf / @0x00C0FFEE

12/29/2010 at 11:20AM

38
#158 - Darcy Parker / @DarcyParker

11/12/2012 at 05:27PM

38
#159 - Brian Olpin / @bolpin

05/03/2014 at 04:45AM

38
#160 - Martin Liberg / @marreman

02/07/2015 at 07:15PM

38
#161 - zmf_tim / @zmf_tim

08/09/2018 at 10:14PM

39
#162 - Alison Rowland / @arowla

12/29/2010 at 05:44AM

39
#163 - Jason Morrison / @jayunit

12/29/2010 at 02:23PM

39
#164 - alexscott / @4l3xsc0tt

12/30/2010 at 02:03AM

39
#165 - Dezső Zoltán / @zakiazigazi

01/22/2011 at 08:40AM

39
#166 - Arto Vuori / @dhpe

08/30/2012 at 09:14PM

39
#167 - Sofia Balicka / @so_phifi

03/05/2013 at 09:09PM

39
#168 - shahanavaz m / @shahanavazm

02/13/2022 at 04:47AM

40
#169 - Paul Tarjan / @ptarjan

12/29/2010 at 06:53AM

40
#170 - Benjaminister / @Benjaminister

12/29/2010 at 07:37AM

40
#171 - omelo / @omelo

12/29/2010 at 08:02AM

40
#172 - johnny / @johnnychm

12/29/2010 at 11:20AM

40
#173 - Daniel Grippi / @danielgrippi

12/31/2010 at 07:45PM

40
#174 - Dave / @zzdave13

07/31/2011 at 10:02PM

40
#175 - Marco Hinz / @_mhinz_

05/22/2013 at 09:57AM

40
#176 - Scott Atkins / @scottrick49

06/15/2021 at 01:54PM

41
#177 - homerj7648 / @homerj7648

12/29/2010 at 05:49AM

41
#178 - Michael Lustfield / @Profarius

12/29/2010 at 06:34AM

41
#179 - emonkak / @emonkak

12/29/2010 at 01:30PM

41
#180 - Andrew McDonough / @andrewmcdonough

12/29/2010 at 06:38PM