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

Reformat/Refactor a Golfer Class

A simple case of removing unneeded code and fixing broken indentation.

Start file
class Golfer
     def initialize; end # initialize
  def useless; end;
  
     def self.hello(a,b,c,d)
      puts "Hello #{a}, #{b}, #{c}, #{d}"
   end
end
End file
class Golfer
  def self.hello(*a)
    puts "Hello #{a.join(',')}"
  end
end

View Diff

2,7c2,4
<      def initialize; end # initialize
<   def useless; end;
<   
<      def self.hello(a,b,c,d)
<       puts "Hello #{a}, #{b}, #{c}, #{d}"
<    end
---
>   def self.hello(*a)
>     puts "Hello #{a.join(',')}"
>   end

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 1364 remaining solutions by signing in and submitting your own entry
#1365 Patrick Muldoon / @d00n - Score: 206 - 12/29/10 @ 15:12
<Esc>:<Up><Up><Up><Up><Up>g.<BS>/.*def.$<BS>*end.*/d<CR>:v/\S/f<BS>d<CR>fai*<Esc><Right><Right>cf))<Esc><Down><Left>i.join(',')<Esc>lldf:df"a"<Esc>=<Esc><Esc><BS><Up><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left>xxxxxi  <Down><Down><Esc>x<Up><Right>xx<Esc>:wq<CR>

0 comments


Created by: @igrigorik

1365 active golfers, 5551 entries

Leaderboard (lowest score wins):
71
#1321 - Dan Quellhorst / @quellhorst

12/28/2010 at 09:59PM

71
#1322 - Михаил Минков / @_x10

08/26/2011 at 10:14AM

71
#1323 - Aaron Snoswell / @aaronsnoswell

09/24/2012 at 03:14PM

72
#1324 - radamant / @radamant

12/28/2010 at 09:34PM

72
#1325 - Phil Webster / @philwebster

03/09/2013 at 02:22AM

73
#1326 - fdsfasdf / @fdsfasdf1

12/14/2011 at 08:13PM

73
#1327 - Zack Brown / @ztbrown

06/30/2014 at 08:50PM

75
#1328 - Toader Mihai Claudiu / @mtoader

12/31/2010 at 11:55AM

76
#1329 - ishmaelahmed / @ishmaelahmed

12/30/2010 at 09:02PM

76
#1330 - Delwyn de Villiers / @delwynd

05/04/2011 at 12:26PM

76
#1331 - Robert Höglund / @rhoglund

07/16/2012 at 03:58PM

76
#1332 - Almog / @almog

01/28/2014 at 01:45PM

77
#1333 - Ben Friedland / @bfriedland174

07/10/2013 at 11:00PM

77
#1334 - Mohit Sharma / @m0hitsharma

12/30/2013 at 02:59AM

77
#1335 - Juan Aguero / @juansta

02/03/2014 at 04:13AM

77
#1336 - Kevin Cooler / @KevinCooler

08/10/2018 at 04:49PM

78
#1337 - kunihiko ito / @kunitoo

04/25/2013 at 12:20PM

78
#1338 - Shunichi Kanade / @shunkana

11/04/2018 at 01:32AM

79
#1339 - Luc Stepniewski / @lstep

12/29/2010 at 02:43PM

79
#1340 - Lee Jones / @scribblethink

09/27/2011 at 02:15PM

80
#1341 - Nanne / @Whazor

12/28/2010 at 10:19PM

81
#1342 - Rap Game Dan Aykroyd / @rapdanaykroyd

02/02/2012 at 06:44PM

82
#1343 - Ed Gibbs / @edward_gibbs

08/01/2011 at 02:23PM

82
#1344 - Ayman Farhat / @aymanfarhat

06/03/2015 at 12:05PM

85
#1345 - Peter Esselius / @esselius

02/19/2013 at 04:20PM

85
#1346 - Huj8228 / @Huj82281

05/06/2013 at 05:15PM

86
#1347 - Alex Budilovsky / @alexbudy

05/04/2018 at 05:47PM

87
#1348 - Blake / @greyblake

12/31/2010 at 01:45AM

88
#1349 - Andy Waite / @andyw8

11/19/2013 at 01:44PM

90
#1350 - geier / @geier

01/30/2012 at 01:04PM