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

1312 active golfers, 5363 entries

Leaderboard (lowest score wins):
32
#61 - ———đίxίє—flαтlίиє——— / @_dixie_flatline

07/20/2013 at 05:21PM

32
#62 - Maximiliano Padulo / @mpadulo

08/06/2013 at 08:53AM

32
#63 - joinvimgolf / @joinvimgolf

08/14/2013 at 07:09PM

32
#64 - Roman Charushin / @lompee

08/21/2013 at 08:58AM

32
#65 - Chris Webb / @chriswebb_42

08/21/2013 at 11:37PM

32
#66 - Jiří Chára / @JiriChara

08/22/2013 at 07:21AM

32
#67 - Stephen Drodge / @sjdrodge

08/24/2013 at 11:36PM

32
#68 - Sam Green / @magpi_

09/12/2013 at 12:02AM

32
#69 - StarkHalo / @hellektor

10/07/2013 at 06:32PM

32
#70 - Trần Lê Anh Minh / @lekima

10/13/2013 at 06:56AM

32
#71 - Song Zheng / @songz

10/15/2013 at 02:10AM

32
#72 - Robert Andersson / @StreamBag

10/23/2013 at 04:57AM

32
#73 - François Marais / @maraisf

11/06/2013 at 01:01PM

32
#74 - Jonathan Potter / @nTypeRed

11/11/2013 at 06:50PM

32
#75 - Ben Zittlau / @benzittlau

11/17/2013 at 07:49PM

32
#76 - digitalronin / @digitalronin

12/08/2013 at 10:49AM

32
#77 - Tim Smart / @tim_smart

12/10/2013 at 02:31AM

32
#78 - ynwsoft / @ynwsoft

12/12/2013 at 02:00PM

32
#79 - Paul Liu / @automorphism

12/18/2013 at 01:49PM

32
#80 - chilicuil / @chilicuil

12/27/2013 at 10:56AM

32
#81 - oliver mueller / @marcontwit

01/09/2014 at 09:13PM

32
#82 - alex scott / @4l3xsc0tt

01/15/2014 at 03:45PM

32
#83 - Christian Welle / @welle_tw

01/20/2014 at 09:37PM

32
#84 - Reese Wilson / @shinyvimgolf

02/03/2014 at 05:56AM

32
#85 - grey wolfs / @grey_wolfs

02/03/2014 at 11:31AM

32
#86 - Michael Morgan / @1n1n1s3

02/03/2014 at 06:08PM

32
#87 - Strabs / @artistavenue

02/05/2014 at 10:00AM

32
#88 - Pedro Santos / @pedrosans

02/13/2014 at 10:26PM

32
#89 - Jeremy Gold / @JeremyGold3

02/14/2014 at 08:22AM

32
#90 - Michael Bitzi / @mibitzi

02/14/2014 at 06:28PM