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

1405 active golfers, 5714 entries

Leaderboard (lowest score wins):
40
#691 - Roman MaĊĦek / @romario333

01/02/2011 at 06:16PM

40
#692 - Grigoriy Glushko / @grinderrz

01/05/2011 at 12:36PM

40
#693 - aimee / @sermoa

01/08/2011 at 02:21PM

40
#694 - James Edward Gray II / @JEG2

04/04/2011 at 12:56AM

40
#695 - Shawn / @sartak

04/22/2011 at 10:50PM

40
#696 - Lauri Tirkkonen / @lotheac

07/01/2011 at 11:17PM

40
#697 - Kubek2k / @kubek2k

09/29/2011 at 10:33PM

40
#698 - johan wester / @wester87

11/12/2011 at 04:27PM

40
#699 - Travis Jeffery / @travisjeffery

12/07/2011 at 12:25AM

40
#700 - Kristopher Urie / @kristopherurie

02/09/2012 at 02:39AM

40
#701 - Vijay Dev / @vijay_dev

02/13/2012 at 09:42AM

40
#702 - Nolen Royalty / @NolenRoyalty

04/20/2012 at 08:30PM

40
#703 - francois bard / @misterfrb

05/04/2012 at 08:53AM

40
#704 - tmr / @tmr314

09/06/2012 at 03:50PM

40
#705 - Andrea Francia / @andreafrancia

10/05/2012 at 07:34PM

40
#706 - Ole Petter Bang / @gnab

10/21/2012 at 08:38PM

40
#707 - xavier kt / @xav_kt

02/01/2013 at 04:19PM

40
#708 - Sean McKenna / @sean__mckenna

04/01/2013 at 09:13PM

40
#709 - Aaron Bieber / @aaronbieber

07/14/2013 at 11:12AM

40
#710 - fSchl / @FelixSchlitter

07/16/2013 at 07:51AM

40
#711 - Bruno Sutic / @brunosutic

07/18/2013 at 05:11AM

40
#712 - Heath Patterson / @HeathPatterson

08/09/2013 at 06:23PM

40
#713 - Sheng / @shenghis

08/25/2013 at 07:55PM

40
#714 - Alonso Torres / @alotor

09/23/2013 at 06:21PM

40
#715 - Volodimir Barna / @RobertoUA

09/30/2013 at 09:21AM

40
#716 - Sami Niiranen / @saminiir

10/13/2013 at 09:42AM

40
#717 - foo / @foo88832727

10/18/2013 at 03:16PM

40
#718 - Alexey Shmalko / @RasenDubi

11/04/2013 at 04:25PM

40
#719 - winterlight / @winterlight4

12/22/2013 at 10:40PM

40
#720 - Herrington Darkholme / @nonamesheep

12/27/2013 at 09:59AM