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

1374 active golfers, 5587 entries

Leaderboard (lowest score wins):
45
#961 - Jesse Brown / @bionicpill

12/29/2010 at 12:54AM

45
#962 - Jon Ferrer / @jonnyheadphones

01/02/2011 at 02:45AM

45
#963 - giggzy / @giggzy

08/13/2011 at 09:24PM

45
#964 - Jonathan Bennett / @jonbca7

11/24/2011 at 06:21AM

45
#965 - Sky Fernandez / @cyberjoeboy

12/14/2011 at 06:55PM

45
#966 - Garrett Davis / @surfprimal

04/02/2012 at 10:44PM

45
#967 - Zifei Tong / @chevalun

09/08/2012 at 11:43AM

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

10/25/2012 at 09:27PM

45
#969 - Roberto Antolín / @Tolanss

03/04/2013 at 07:44PM

45
#970 - Simon Tost / @Someone_Busy

03/09/2013 at 08:43AM

45
#971 - Martin Keogh / @Martin1Keogh

03/31/2013 at 03:28PM

45
#972 - Kathryn / @hartknyx

05/17/2013 at 01:44AM

45
#973 - Andrew Noyes / @seyonwerdna

07/08/2013 at 07:09AM

45
#974 - retired account / @retired10072015

08/24/2013 at 10:12AM

45
#975 - Andrew Crites / @ExplosionPills

09/12/2013 at 02:33PM

45
#976 - nona urbiz / @nospampleasemam

09/28/2013 at 10:55AM

45
#977 - Ben Pringle / @pringleben

10/22/2013 at 12:07AM

45
#978 - LumberCoder / @LuRsT

01/28/2014 at 06:38PM

45
#979 - Mina Naguib / @minaguib

02/18/2014 at 03:41AM

45
#980 - Rajit Singh / @rajitbsingh

02/21/2014 at 05:02PM

45
#981 - Peter Strawson / @PeterStrawson

04/08/2014 at 09:25PM

45
#982 - Martijn Theunissen / @Damnesia__

06/13/2014 at 12:11AM

45
#983 - glennphillips / @glennphillips

07/09/2014 at 09:06PM

45
#984 - João Carvalho / @joaoCarvas

07/11/2014 at 12:30PM

45
#985 - Yoonho Lee / @ID_einet89

07/25/2014 at 09:24AM

45
#986 - Kristian Jagd / @Jagdos

09/07/2014 at 10:44AM

45
#987 - Christoph Neuroth / @c089

10/18/2014 at 10:31AM

45
#988 - Pedro Franceschi / @pedroh96

11/10/2014 at 11:01PM

45
#989 - Xiaocan Li / @XiaocanLi

02/29/2016 at 05:32PM

45
#990 - Mike G / @MikeG39938619

03/18/2016 at 10:41AM