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 1398 remaining solutions by signing in and submitting your own entry
#1399 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

1399 active golfers, 5693 entries

Leaderboard (lowest score wins):
44
#961 - Chris Ciulla / @chris_ciulla

01/30/2014 at 01:48AM

44
#962 - Jae Won Kim / @jaewone

02/03/2014 at 07:29AM

44
#963 - Space Sloth / @daspacesloth

03/05/2014 at 05:24PM

44
#964 - Solar Powered Robot / @moskrin

05/01/2014 at 06:35PM

44
#965 - Harald H / @metellius

08/20/2014 at 10:21AM

44
#966 - Daniel Burnett / @mango_cheetah

10/10/2014 at 04:51PM

44
#967 - Aaron Whittington / @whittaaron

01/16/2015 at 03:09AM

44
#968 - Mark Saiget / @MarkSaiget

04/22/2015 at 03:34AM

44
#969 - Carsten Lenz / @carstenlenz

05/03/2015 at 06:12PM

44
#970 - Brian Besmanoff / @BrianBesmanoff

08/06/2015 at 05:34AM

44
#971 - Alex Bartol / @alexbartol

09/15/2015 at 06:05PM

44
#972 - Thomas Williams / @neopsalmist

01/06/2016 at 02:47PM

44
#973 - Clémence / @Clemence_Neoxia

05/23/2016 at 07:31AM

44
#974 - Will / @obiwan__k3n00bi

08/14/2016 at 10:47PM

44
#975 - Mark Brody / @_markbrody

03/23/2017 at 05:37AM

44
#976 - Geoff / @RealGeoffErwin

09/29/2017 at 06:52PM

44
#977 - たぬぽん / @eJYwMbymauWKF4B

06/11/2019 at 12:23PM

44
#978 - David Barker / @dashleybarker

12/31/2019 at 04:54PM

44
#979 - countime / @countime1

03/11/2020 at 12:32AM

45
#980 - Jesse Brown / @bionicpill

12/29/2010 at 12:54AM

45
#981 - Jon Ferrer / @jonnyheadphones

01/02/2011 at 02:45AM

45
#982 - giggzy / @giggzy

08/13/2011 at 09:24PM

45
#983 - Jonathan Bennett / @jonbca7

11/24/2011 at 06:21AM

45
#984 - Sky Fernandez / @cyberjoeboy

12/14/2011 at 06:55PM

45
#985 - Garrett Davis / @surfprimal

04/02/2012 at 10:44PM

45
#986 - Zifei Tong / @chevalun

09/08/2012 at 11:43AM

45
#987 - Tóth Balázs / @tthbalazs

10/25/2012 at 09:27PM

45
#988 - Roberto Antolín / @Tolanss

03/04/2013 at 07:44PM

45
#989 - Simon Tost / @Someone_Busy

03/09/2013 at 08:43AM

45
#990 - Martin Keogh / @Martin1Keogh

03/31/2013 at 03:28PM