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

1369 active golfers, 5569 entries

Leaderboard (lowest score wins):
45
#961 - Sky Fernandez / @cyberjoeboy

12/14/2011 at 06:55PM

45
#962 - Garrett Davis / @surfprimal

04/02/2012 at 10:44PM

45
#963 - Zifei Tong / @chevalun

09/08/2012 at 11:43AM

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

10/25/2012 at 09:27PM

45
#965 - Roberto Antolín / @Tolanss

03/04/2013 at 07:44PM

45
#966 - Simon Tost / @Someone_Busy

03/09/2013 at 08:43AM

45
#967 - Martin Keogh / @Martin1Keogh

03/31/2013 at 03:28PM

45
#968 - Kathryn / @hartknyx

05/17/2013 at 01:44AM

45
#969 - Andrew Noyes / @seyonwerdna

07/08/2013 at 07:09AM

45
#970 - retired account / @retired10072015

08/24/2013 at 10:12AM

45
#971 - Andrew Crites / @ExplosionPills

09/12/2013 at 02:33PM

45
#972 - nona urbiz / @nospampleasemam

09/28/2013 at 10:55AM

45
#973 - Ben Pringle / @pringleben

10/22/2013 at 12:07AM

45
#974 - LumberCoder / @LuRsT

01/28/2014 at 06:38PM

45
#975 - Mina Naguib / @minaguib

02/18/2014 at 03:41AM

45
#976 - Rajit Singh / @rajitbsingh

02/21/2014 at 05:02PM

45
#977 - Peter Strawson / @PeterStrawson

04/08/2014 at 09:25PM

45
#978 - Martijn Theunissen / @Damnesia__

06/13/2014 at 12:11AM

45
#979 - glennphillips / @glennphillips

07/09/2014 at 09:06PM

45
#980 - João Carvalho / @joaoCarvas

07/11/2014 at 12:30PM

45
#981 - Yoonho Lee / @ID_einet89

07/25/2014 at 09:24AM

45
#982 - Kristian Jagd / @Jagdos

09/07/2014 at 10:44AM

45
#983 - Christoph Neuroth / @c089

10/18/2014 at 10:31AM

45
#984 - Pedro Franceschi / @pedroh96

11/10/2014 at 11:01PM

45
#985 - Xiaocan Li / @XiaocanLi

02/29/2016 at 05:32PM

45
#986 - Mike G / @MikeG39938619

03/18/2016 at 10:41AM

45
#987 - William Robson / @wnrbs

08/11/2016 at 11:07PM

45
#988 - 이선협 / @kciter

09/02/2016 at 09:07AM

46
#989 - rabidpraxis / @rabidpraxis

12/31/2010 at 05:03AM

46
#990 - fukamikaze / @fukamikaze

01/01/2011 at 03:42AM