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 5675405ac5936f0ba3000002

Create bison tokens

Create tokens for bison out of a known list of words

Start file
call real integer write read while end do if then else program var begin return include
End file
call {
	yylval.type = strdup("res");
	yylval.value = strdup(yytext);
	return Call;
}
real {
	yylval.type = strdup("res");
	yylval.value = strdup(yytext);
	return Real;
}
integer {
	yylval.type = strdup("res");
	yylval.value = strdup(yytext);
	return Integer;
}
write {
	yylval.type = strdup("res");
	yylval.value = strdup(yytext);
	return Write;
}
read {
	yylval.type = strdup("res");
	yylval.value = strdup(yytext);
	return Read;
}
while {
	yylval.type = strdup("res");
	yylval.value = strdup(yytext);
	return While;
}
end {
	yylval.type = strdup("res");
	yylval.value = strdup(yytext);
	return End;
}
do {
	yylval.type = strdup("res");
	yylval.value = strdup(yytext);
	return Do;
}
if {
	yylval.type = strdup("res");
	yylval.value = strdup(yytext);
	return If;
}
then {
	yylval.type = strdup("res");
	yylval.value = strdup(yytext);
	return Then;
}
else {
	yylval.type = strdup("res");
	yylval.value = strdup(yytext);
	return Else;
}
program {
	yylval.type = strdup("res");
	yylval.value = strdup(yytext);
	return Program;
}
var {
	yylval.type = strdup("res");
	yylval.value = strdup(yytext);
	return Var;
}
begin {
	yylval.type = strdup("res");
	yylval.value = strdup(yytext);
	return Begin;
}
return {
	yylval.type = strdup("res");
	yylval.value = strdup(yytext);
	return Return;
}
include {
	yylval.type = strdup("res");
	yylval.value = strdup(yytext);
	return Include;
}

View Diff

1c1,80
< call real integer write read while end do if then else program var begin return include
---
> call {
> 	yylval.type = strdup("res");
> 	yylval.value = strdup(yytext);
> 	return Call;
> }
> real {
> 	yylval.type = strdup("res");
> 	yylval.value = strdup(yytext);
> 	return Real;
> }
> integer {
> 	yylval.type = strdup("res");
> 	yylval.value = strdup(yytext);
> 	return Integer;
> }
> write {
> 	yylval.type = strdup("res");
> 	yylval.value = strdup(yytext);
> 	return Write;
> }
> read {
> 	yylval.type = strdup("res");
> 	yylval.value = strdup(yytext);
> 	return Read;
> }
> while {
> 	yylval.type = strdup("res");
> 	yylval.value = strdup(yytext);
> 	return While;
> }
> end {
> 	yylval.type = strdup("res");
> 	yylval.value = strdup(yytext);
> 	return End;
> }
> do {
> 	yylval.type = strdup("res");
> 	yylval.value = strdup(yytext);
> 	return Do;
> }
> if {
> 	yylval.type = strdup("res");
> 	yylval.value = strdup(yytext);
> 	return If;
> }
> then {
> 	yylval.type = strdup("res");
> 	yylval.value = strdup(yytext);
> 	return Then;
> }
> else {
> 	yylval.type = strdup("res");
> 	yylval.value = strdup(yytext);
> 	return Else;
> }
> program {
> 	yylval.type = strdup("res");
> 	yylval.value = strdup(yytext);
> 	return Program;
> }
> var {
> 	yylval.type = strdup("res");
> 	yylval.value = strdup(yytext);
> 	return Var;
> }
> begin {
> 	yylval.type = strdup("res");
> 	yylval.value = strdup(yytext);
> 	return Begin;
> }
> return {
> 	yylval.type = strdup("res");
> 	yylval.value = strdup(yytext);
> 	return Return;
> }
> include {
> 	yylval.type = strdup("res");
> 	yylval.value = strdup(yytext);
> 	return Include;
> }

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 17 remaining solutions by signing in and submitting your own entry
#18 Alexander Botticelli / @BotticelliAlex - Score: 125 - 12/19/15 @ 11:49
q2wi<CR><Esc>kA{<CR><Tab>yylval.type = strdup("res");<Esc>yypwwciwvalue<Esc>4wci(yytr<BS>ext<Esc>kkbviwy2jA<CR>return ;<Esc>Pb~A<CR>}<Esc>i<BS><Esc>jq@<Esc>15@2ddkA<BS>e;<Esc>kkkie <Esc>:wq<CR>

0 comments


Created by: @BotticelliAlex

18 active golfers, 47 entries

Leaderboard (lowest score wins):
85
#1 - Smylers / @Smylers2

02/11/2016 at 02:44PM

85
#2 - Urtica dioica / @udioica

01/12/2017 at 02:02AM

85
#3 - John Braxler / @braxler

08/10/2018 at 01:53PM

85
#4 - Peppa Pig / @PeppaPi95550250

07/03/2024 at 01:00AM

85
#5 - nickGPT / @nickandbro

08/28/2024 at 03:40AM

86
#6 - Jon Krause / @jkrause314

12/21/2015 at 06:51PM

86
#7 - vimgolfer / @vimgolfer7

10/06/2019 at 04:10AM

89
#8 - sellerie schnitzel / @sellerieschnitz

12/20/2015 at 05:26PM

89
#9 - Carlos A Henríquez Q / @lagunex

03/13/2016 at 04:22PM

93
#10 - Bennett / @bennettbackward

12/20/2018 at 09:09AM

97
#11 - Walker Boh / @walker_boh

12/21/2015 at 03:56PM

102
#12 - Mikael Saltzman / @MikaelSaltzman

12/27/2015 at 03:18PM

103
#13 - RobertT / @techrt2050

01/25/2016 at 03:57AM

105
#14 - Frederik Klama / @fklama

01/27/2016 at 03:37PM

110
#15 - Tj / @yrddy

03/02/2016 at 02:36AM

115
#16 - Håken Lid / @haakenlid

12/27/2015 at 03:06PM

116
#17 - Christopher Wells / @ExcaliburZero_Z

12/20/2015 at 04:19AM

125
#18 - Alexander Botticelli / @BotticelliAlex

12/19/2015 at 11:49AM