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):
28
#61 - Nick Bakkegaard / @Bakkemand

11/26/2012 at 10:38PM

28
#62 - Quota / @Quotad

01/29/2014 at 02:45PM

28
#63 - ryk / @rykarn

03/29/2014 at 02:11PM

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

06/28/2015 at 07:56PM

28
#65 - tPenguinLTG / @tpenguinltg

05/01/2016 at 08:37PM

28
#66 - Curt Matz / @sitrucz

02/09/2017 at 04:27PM

28
#67 - Michał / @Micha46184564

11/14/2020 at 02:56PM

28
#68 - wutwere / @wutwere

06/30/2024 at 10:36PM

28
#69 - gnragazzi / @gnragazzi

07/29/2024 at 12:29AM

28
#70 - Alex Khakhlyuk / @khakhlyuk

08/22/2024 at 09:01PM

28
#71 - Tsimon Dorakh / @Tsimon-Dorakh

10/28/2024 at 02:10PM

29
#72 - Ben C / @cben

12/29/2010 at 05:23AM

29
#73 - ehc / @ehc

12/29/2010 at 08:23AM

29
#74 - marklu / @marklu

12/29/2010 at 09:45AM

29
#75 - Simon Edwardsson / @_SimEdw_

12/29/2010 at 04:45PM

29
#76 - uuu / @uu59

12/30/2010 at 12:48AM

29
#77 - Steve Morrow / @yawmark

12/30/2010 at 04:38AM

29
#78 - Naveed Massjouni / @ironcamel

12/31/2010 at 07:02AM

29
#79 - mightyfoo / @mightyfoo

05/26/2011 at 01:45AM

29
#80 - Jim Infield / @jinfield

07/20/2011 at 02:40PM

29
#81 - じょんあば / @john_ababa

02/23/2012 at 08:07AM

29
#82 - Tyler / @tylerbindon

10/26/2013 at 02:10PM

29
#83 - Walker Boh / @walker_boh

11/27/2015 at 09:45AM

29
#84 - Matti Sairanen / @MattiSairanen

07/14/2017 at 08:15AM

29
#85 - Mihai / @mihaicristiant

03/18/2019 at 10:28AM

29
#86 - Ebi / @ehan6

08/16/2020 at 01:18PM

29
#87 - Sean Corr / @seanc01212

02/20/2022 at 12:41AM

30
#88 - Paul Heideman / @paulheideman

12/29/2010 at 12:31PM

30
#89 - Ben Lenarts / @benlenarts

12/30/2010 at 11:14AM

30
#90 - nicolas bo / @thevegeta

11/15/2011 at 04:19PM