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):
22
#1 - Miłosz Łakomy / @foobar01123

05/02/2020 at 03:43AM

22
#2 - Jean George / @JeanGeo20504212

04/22/2022 at 07:18AM

22
#3 - Qing Liu / @poeminlash

08/07/2022 at 02:50AM

22
#4 - Zion Park / @zionpark93

01/09/2023 at 01:57AM

22
#5 - Peppa Pig / @PeppaPigSg

06/01/2024 at 04:10PM

23
#6 - Urtica dioica / @udioica

01/11/2014 at 06:55AM

23
#7 - John Braxler / @braxler

12/22/2014 at 02:36PM

23
#8 - Карл / @tb_ism

07/24/2021 at 12:05AM

24
#9 - weiss-i-net / @weiss-i-net

05/26/2024 at 10:45PM

25
#10 - Renat Aksitov / @Korvin79

02/15/2012 at 12:27PM

25
#11 - drupalovereasy / @drupalovereasy

04/29/2012 at 09:15AM

25
#12 - Charles Gordon / @liberalbias

08/26/2012 at 05:13PM

25
#13 - tmr / @tmr314

09/05/2012 at 05:09PM

25
#14 - Hubba / @HubbaBubbaFett

12/13/2012 at 09:44PM

25
#15 - xavier kt / @xav_kt

02/05/2013 at 12:08AM

25
#16 - Petro Тrouq / @zulolosi

07/21/2013 at 12:48AM

25
#17 - Yann Moisan / @YannMoisan

01/04/2014 at 12:00AM

25
#18 - vimgolf copycat / @vimgolf_copycat

03/08/2014 at 03:32PM

25
#19 - david hu / @chin33z

12/21/2014 at 05:03AM

25
#20 - BartJanssen / @BartJanssen

03/15/2015 at 11:04PM

25
#21 - Melvin Cheung / @MelvinCheung

05/25/2017 at 06:49AM

25
#22 - Turkey Man / @lvturkeyman

11/27/2017 at 04:20PM

25
#23 - DHM / @DHM29978992

05/15/2018 at 02:16AM

25
#24 - Filipe Brandenburger / @filbranden

07/08/2019 at 12:30AM

25
#25 - Lory / @Lory46845742

12/17/2019 at 11:06AM

25
#26 - Александр Моисеев / @Aleksan43607471

01/23/2023 at 12:49PM

25
#27 - tianxiaweiyidao / @tianxiaweiyidao

04/20/2024 at 06:00AM

25
#28 - bounce114 / @bounce114

12/03/2024 at 06:32AM

26
#29 - Balkoth / @_Balkoth_

01/08/2011 at 05:35PM

26
#30 - Federico Galassi / @federicogalassi

01/31/2011 at 12:49AM