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 by @hihgl:

Unlock 11 remaining solutions by signing in and submitting your own entry
Created by: @sabiddle

316 active golfers, 1018 entries

Solutions by @hihgl:
34
#30 - Glen Huang / @hihgl

07/14/2023 at 05:02AM

35
#>48 - Glen Huang / @hihgl

07/14/2023 at 04:59AM

36
#>52 - Glen Huang / @hihgl

07/14/2023 at 04:56AM

37
#>65 - Glen Huang / @hihgl

07/14/2023 at 04:55AM

38
#>77 - Glen Huang / @hihgl

07/14/2023 at 04:53AM

40
#>96 - Glen Huang / @hihgl

07/14/2023 at 04:48AM

42
#>126 - Glen Huang / @hihgl

07/14/2023 at 04:47AM

43
#>140 - Glen Huang / @hihgl

07/14/2023 at 04:44AM

44
#>151 - Glen Huang / @hihgl

07/14/2023 at 04:39AM

50
#>234 - Glen Huang / @hihgl

07/14/2023 at 04:37AM

52
#>256 - Glen Huang / @hihgl

07/14/2023 at 04:28AM