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):
29
#61 - Ben C / @cben

12/29/2010 at 05:23AM

29
#62 - ehc / @ehc

12/29/2010 at 08:23AM

29
#63 - marklu / @marklu

12/29/2010 at 09:45AM

29
#64 - Simon Edwardsson / @_SimEdw_

12/29/2010 at 04:45PM

29
#65 - uuu / @uu59

12/30/2010 at 12:48AM

29
#66 - Steve Morrow / @yawmark

12/30/2010 at 04:38AM

29
#67 - Naveed Massjouni / @ironcamel

12/31/2010 at 07:02AM

29
#68 - mightyfoo / @mightyfoo

05/26/2011 at 01:45AM

29
#69 - Jim Infield / @jinfield

07/20/2011 at 02:40PM

29
#70 - 無ん垢の叫び / @john_ababa

02/23/2012 at 08:07AM

29
#71 - Tyler / @tylerbindon

10/26/2013 at 02:10PM

29
#72 - Walker Boh / @walker_boh

11/27/2015 at 09:45AM

29
#73 - Matti Sairanen / @MattiSairanen

07/14/2017 at 08:15AM

29
#74 - Mihai / @mihaicristiant

03/18/2019 at 10:28AM

29
#75 - Ebi / @ehan6

08/16/2020 at 01:18PM

29
#76 - Sean Corr / @seanc01212

02/20/2022 at 12:41AM

30
#77 - Paul Heideman / @paulheideman

12/29/2010 at 12:31PM

30
#78 - Ben Lenarts / @benlenarts

12/30/2010 at 11:14AM

30
#79 - nicolas bo / @thevegeta

11/15/2011 at 04:19PM

30
#80 - Christopher Brew / @Seph1rothVII

02/06/2012 at 06:03PM

30
#81 - ajh / @AlexJHammel

12/24/2012 at 05:06PM

30
#82 - a24f0600 / @a24f0600

01/08/2013 at 03:48PM

30
#83 - Aaron Josephs / @aaronjosephs1

05/02/2013 at 02:03AM

30
#84 - Gurukandhamoorthi / @Gurukandhamoor1

08/08/2017 at 05:06PM

31
#85 - Andrew Scala / @agscala

12/29/2010 at 05:24AM

31
#86 - libicocco / @libicocco

12/29/2010 at 12:51PM

31
#87 - Mariano Guerra / @marianoguerra

12/29/2010 at 04:09PM

31
#88 - Juan C. Muller / @juancmuller

12/31/2010 at 04:30AM

31
#89 - Guillaume Bonnoron / @gbonnoron

12/31/2010 at 11:50AM

31
#90 - Jordi Romero / @jordiromero

01/07/2011 at 09:31PM