For completeness - same task in vim:
start recording a macro:
qa
Then enter this sequence of keystrokes[1]:
0veyO// Run the ^R" commandj0f.C()end
Then exit macro recording with:
q
Then enter the command:
:g/.rb$/ norm @a
to run the macro on every line ending with .rb (allowing comments in the input, just because (of course it would be nice to make that regex in :g look for "lines that start with comments" and ignore them explicitly)).
If I counted right, thats 57 keystrokes, and I might have been slightly inefficient in my usage, of course, if that one keystroke is part of a command my fingers just do, there is no effective difference :)
[1] I know it was exactly that sequence because I just pasted the macro buffer, which of course can then be edited, saved back to the buffer and run in edited form.