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):
41
#181 - Sammasati / @sammasati0

07/15/2011 at 06:41PM

42
#182 - Sid Kasivajhula / @CountVajhula

12/29/2010 at 08:10AM

43
#183 - Aaron Bull Schaefer / @elasticdog

12/29/2010 at 04:20PM

43
#184 - Adam / @ulbador

12/29/2010 at 09:56PM

43
#185 - Francisco Dibar / @frandibar

01/13/2011 at 03:19AM

43
#186 - Craig H. Anderson / @CootCraig

04/22/2011 at 08:10PM

44
#187 - togi / @togi

12/29/2010 at 05:52PM

44
#188 - Nick / @quinks25

01/13/2011 at 10:54AM

44
#189 - wusher / @wusher

06/02/2011 at 07:57PM

44
#190 - anonymouse / @anonymo65837183

04/12/2022 at 03:08AM

44
#191 - SmoggyFog / @SmoggyFog

06/02/2023 at 01:29AM

45
#192 - Sasha Koss / @kossnocorp

12/29/2010 at 07:51AM

45
#193 - Aleksander Balicki / @alekbalicki

12/29/2010 at 02:41PM

46
#194 - Andrey A. Ugolnik / @andreyugolnik

01/19/2011 at 07:00PM

46
#195 - Trevor Powell / @DoomedBunnies

11/28/2011 at 05:22AM

46
#196 - Oliver Christ / @0liverChrist

02/13/2015 at 06:02PM

47
#197 - Chad Waters / @cgwaters

12/29/2010 at 02:38PM

48
#198 - Behnam Esfahbod / @zwnj

12/30/2010 at 12:50PM

49
#199 - Alain Gilbert / @alain_gilbert

12/30/2010 at 06:55PM

50
#200 - Brad / @bjjwillis

12/30/2010 at 01:35AM

50
#201 - solsTiCe d'Hiver / @solstice_dhiver

12/30/2010 at 05:56PM

50
#202 - Timothy Hahn / @timyhahn

04/20/2012 at 03:49AM

51
#203 - Phil / @phil30075

12/29/2010 at 05:27AM

52
#204 - drio / @drio

01/01/2011 at 01:46AM

53
#205 - FAKECAMGRAY / @FAKECAMGRAY

11/28/2011 at 12:26AM

79
#206 - Arjen Schat / @arjenschat

12/29/2010 at 02:50PM

96
#207 - Xin Xie / @xxie24

12/31/2010 at 01:19AM

96
#208 - nickGPT / @nickandbro

08/29/2024 at 12:09AM

126
#209 - Frank Hui / @frankhui

12/29/2010 at 06:39AM