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):
31
#91 - Oleg Roshupkin / @jjjahson

01/21/2011 at 01:01PM

31
#92 - Wesley Wong / @wesleymwwong

01/30/2011 at 10:10AM

31
#93 - RusAlex Pletnev / @RusAlexander

06/22/2012 at 09:15PM

31
#94 - cj / @cj01101

01/30/2014 at 08:07PM

31
#95 - Henry Dang / @henrydangchs

10/25/2017 at 08:47PM

32
#96 - pcapriotti / @pcapriotti

12/29/2010 at 11:37AM

32
#97 - Akira Matsuda / @a_matsuda

12/30/2010 at 04:42PM

32
#98 - greg / @kongo2002

12/31/2010 at 12:12AM

32
#99 - xhtmlforum / @xhtmlforum

02/01/2011 at 10:20PM

32
#100 - Joost / @vlabakje

02/20/2011 at 01:27PM

32
#101 - Vimgolf Pikob / @vimgolfpikob

12/08/2012 at 10:33PM

32
#102 - Johan Berg / @_berg85

01/24/2014 at 03:23PM

32
#103 - bratliff / @bratliff

08/10/2014 at 07:43AM

32
#104 - James / @Dronak

09/18/2014 at 08:39PM

32
#105 - Hugo / @szeyattai

08/20/2018 at 09:10AM

33
#106 - Matt Edlefsen / @mattedlefsen

12/29/2010 at 08:19AM

33
#107 - Pierre / @Pihour

01/02/2011 at 04:19PM

33
#108 - vansan / @VinceVansan

08/26/2012 at 06:25PM

33
#109 - くま ก็็็็็็็็็็็็็ʕ•͡ᴥ•ʔ ก้้้้้้้้้้้ 55 / @kumack55

04/10/2013 at 12:53AM

33
#110 - Justin Knag / @justinknag

09/16/2014 at 05:46AM

33
#111 - Mauro Persano / @fzort

11/20/2014 at 08:38PM

33
#112 - russellzhaomao / @russellzhaomao

05/28/2022 at 01:30PM

34
#113 - timotheo / @timotheo

12/29/2010 at 06:04AM

34
#114 - Corbin Simpson / @corbinsimpson

12/29/2010 at 07:27AM

34
#115 - Ruben Gomez / @AccedoSW

12/29/2010 at 08:19AM

34
#116 - Andrei Chirila / @andrei_chirila

12/30/2010 at 04:39PM

34
#117 - 藤田祥 / Sho Fujita / @fujisho

12/31/2010 at 01:13PM

34
#118 - h_east (トロッコ6個) / @h_east

01/15/2011 at 06:22PM

34
#119 - Rolf K. / @mindleftbody

06/17/2011 at 01:23PM

34
#120 - Nolen Royalty / @NolenRoyalty

04/20/2012 at 07:31PM