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):
33
#121 - くま ก็็็็็็็็็็็็็ʕ•͡ᴥ•ʔ ก้้้้้้้้้้้ 55 / @kumack55

04/10/2013 at 12:53AM

33
#122 - Justin Knag / @justinknag

09/16/2014 at 05:46AM

33
#123 - Mauro Persano / @fzort

11/20/2014 at 08:38PM

33
#124 - russellzhaomao / @russellzhaomao

05/28/2022 at 01:30PM

33
#125 - Buatvimgolf / @buatvimgolf

07/05/2022 at 09:45AM

34
#126 - timotheo / @timotheo

12/29/2010 at 06:04AM

34
#127 - Corbin Simpson / @corbinsimpson

12/29/2010 at 07:27AM

34
#128 - Ruben Gomez / @AccedoSW

12/29/2010 at 08:19AM

34
#129 - Andrei Chirila / @andrei_chirila

12/30/2010 at 04:39PM

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

12/31/2010 at 01:13PM

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

01/15/2011 at 06:22PM

34
#132 - Rolf K. / @mindleftbody

06/17/2011 at 01:23PM

34
#133 - Nolen Royalty / @NolenRoyalty

04/20/2012 at 07:31PM

34
#134 - Casper Christensen / @Casper__C

11/26/2012 at 02:40PM

34
#135 - brett / @brettyukich

09/24/2013 at 09:53AM

34
#136 - Brian / @wyantb_reader

06/26/2014 at 11:00AM

34
#137 - albalitz / @_albalitz

06/18/2019 at 01:44PM

35
#138 - Leonard Chin / @lchin

12/29/2010 at 02:15PM

35
#139 - Cristi Balan / @evilchelu

01/01/2011 at 07:37AM

35
#140 - Hartator / @Hartator

05/27/2011 at 03:38PM

35
#141 - You-Siang Lin / @yslinnctu

11/29/2011 at 02:46PM

35
#142 - Maciej Suchecki / @mcSuchecki

12/11/2011 at 12:28AM

35
#143 - じょり / @jyori112

06/03/2021 at 03:05PM

35
#144 - Michel Viktor / @tomkpz

07/29/2021 at 02:21AM

36
#145 - Takayuki Tsukitani / @tsukkee

12/30/2010 at 06:27AM

36
#146 - Vincent Isambart / @vincentisambart

12/31/2010 at 11:40AM

36
#147 - Philipp / @klmann232

01/10/2011 at 12:35AM

36
#148 - Cameron White / @_cameronwhite

01/11/2011 at 05:39AM

36
#149 - Kyle Fuller / @kylefuller

04/15/2012 at 07:52PM

36
#150 - うえっち / @uh_tomo

12/05/2012 at 07:07AM