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 4d1a522ea860b7447200010b

Braces or Brackets?

Someone forgot whether to use braces or brackets and you have to clean up their code!

Start file
var some_function = function {arg1, arg2} [
	var some_array = (1, 2, 3, 4, 'foo');
	for {var i in some_array} (
		console.log(some_array, [{1 + (8 / 2)}, 'hello (world)');
	)
];
End file
var some_function = function (arg1, arg2) {
	var some_array = [1, 2, 3, 4, 'foo'];
	for (var i in some_array) {
		console.log(some_array, [(1 + (8 / 2)), 'hello (world)');
	}
};

View Diff

1,6c1,6
< var some_function = function {arg1, arg2} [
<       var some_array = (1, 2, 3, 4, 'foo');
<       for {var i in some_array} (
<               console.log(some_array, [{1 + (8 / 2)}, 'hello (world)');
<       )
< ];
---
> var some_function = function (arg1, arg2) {
>       var some_array = [1, 2, 3, 4, 'foo'];
>       for (var i in some_array) {
>               console.log(some_array, [(1 + (8 / 2)), 'hello (world)');
>       }
> };

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 311 remaining solutions by signing in and submitting your own entry
#312 biloute02 / @biloute02 - Score: 523 - 04/27/24 @ 12:16
<Esc>:g<BS>_<BS>+<BS>!@#$<BS><BS><BS><BS>&*()<BS><BS><BS><BS>()_+<BS><BS><BS><BS>1<BS>[]\<BS><BS>!<BS><BS>1<BS>[]\'{}|<BS><BS><BS><BS><BS><BS>_)(*&^%$#@!<BS><BS><BS><BS><BS><BS><BS><BS><BS><BS><BS><BS>+_)(*&^%$#@!<BS><BS><BS><BS><BS><BS><BS><BS><BS><BS><BS><BS>%^<BS><BS>%s<BS>s.<BS>/<Esc>xu:s?<BS><BS>gs<BS><BS>5<BS>%<BS>%s<CR>:mn<BS>an :s<CR>V<Esc>:,<BS>.f<BS><BS>s<BS>g<BS>k<BS>l<BS>hl<BS>elp :c<BS>s<CR><C-D><C-U><C-D><C-D><C-D><C-U><C-U><C-U><C-D><C-D><C-D><C-D><C-D><C-D><C-D><C-D><C-D><C-D><C-D><C-D><C-D><C-D><C-U><C-U>:hie<BS><BS>u<BS>f<BS>o<BS>l<BS>e<BS>elp range<CR>:%/{/[?<BS>/g<CR>q:<Up><Right>is<CR><Esc><Esc>:q<CR>q:<Up><Up><CR>:<Esc>s<Esc>uuq:<Up><Right><Right><Right><Right><Right>r0r)r(<CR>q:<Up><Right><Right><Right>r}llr)<CR>q:<Up><Right><Right><Right>r[llr{<CR>f<Esc>q:<Down><Up><Right><Right><Right>i><BS>?<BS>'|"<BS><BS><BS><><BS><BS>/?<BS><BS>M<<BS><BS>:;<BS><BS>"|'\<BS><BS><BS><BS><Esc>/<Esc><Esc><Right><Left><Right>i-++_<BS><BS><BS><BS>!@#$%^&*()+_)(<BS><BS><BS><BS><BS><BS><BS><BS><BS><BS><BS><BS><BS><BS>:?><MM,./;l'\]<BS><BS><BS><BS><BS><BS><BS><BS><BS><BS><BS><BS><BS><BS>\\|<BS><BS><Right><Right>|<BS>\<CR>q:<Up><Right><Right><Right><Right>r]lll]}r}<CR>klr}kkA<BS>}<BS>{<Esc>p<Esc>sk<BS><Esc>jllllllrslhrJr(<Up><Up><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left>r[]<Esc>wwwwwweeeeehr]<Down><Down><Left><Left><Left>r[<Esc>:c<BS>x<CR>

0 comments


Created by: @sabiddle

312 active golfers, 969 entries

Leaderboard (lowest score wins):
34
#1 - Renat Aksitov / @Korvin79

01/28/2012 at 05:02PM

34
#2 - Rod Knowlton / @codelahoma

05/26/2012 at 08:49PM

34
#3 - Urtica dioica / @udioica

06/09/2012 at 02:08AM

34
#4 - John Piasetzki / @jpiasetz

07/13/2012 at 03:56AM

34
#5 - lwjef / @lwjef

08/15/2012 at 12:34PM

34
#6 - Charles Gordon / @liberalbias

08/24/2012 at 02:02AM

34
#7 - Conner McDaniel / @connermcd

09/18/2012 at 05:09PM

34
#8 - Victor Ramirez / @virako

10/01/2012 at 10:47AM

34
#9 - Vim rocks / @vimrocks

10/06/2012 at 11:38AM

34
#10 - a24f0600 / @a24f0600

12/14/2012 at 09:07AM

34
#11 - Averell Dalton / @webtwoosucks

01/02/2013 at 10:22PM

34
#12 - Jimmy Mabey / @mabeyj

01/20/2013 at 02:26AM

34
#13 - Yann Moisan / @YannMoisan

02/01/2013 at 02:46PM

34
#14 - xavier kt / @xav_kt

02/04/2013 at 08:14PM

34
#15 - Petro Тrouq / @zulolosi

03/27/2013 at 12:26AM

34
#16 - Bradd Szonye / @bszonye

07/14/2013 at 08:26AM

34
#17 - John Braxler / @braxler

04/16/2014 at 08:07PM

34
#18 - kimber gonzalez / @kimberlycreates

01/22/2015 at 02:51PM

34
#19 - pftb12345 / @pftb12345

04/12/2015 at 01:32PM

34
#20 - Jon Krause / @jkrause314

01/11/2016 at 09:56PM

34
#21 - Turkey Man / @lvturkeyman

11/26/2017 at 07:37AM

34
#22 - Miłosz Łakomy / @foobar01123

02/15/2020 at 04:35AM

34
#23 - Jung Yeon Park / @park_jungy

08/08/2021 at 07:20PM

34
#24 - yancy / @yancy_dong

04/29/2022 at 06:32AM

34
#25 - josh / @_zvjos

06/18/2022 at 12:59PM

34
#26 - Andreas Näsman / @andreas_nasman

06/19/2022 at 06:06PM

34
#27 - Qing Liu / @poeminlash

07/23/2022 at 11:26PM

34
#28 - math is what I hate / @mpnmbn

10/29/2022 at 06:04PM

34
#29 - Zion Park / @zionpark93

12/14/2022 at 09:01PM

34
#30 - Glen Huang / @hihgl

07/14/2023 at 05:02AM