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

1885 active golfers, 7658 entries

Leaderboard (lowest score wins):
32
#31 - James Davis / @tripvg

08/03/2012 at 07:12PM

32
#32 - Sean Griffin / @sgrif

08/12/2012 at 07:57PM

32
#33 - lwjef / @lwjef

08/13/2012 at 05:48AM

32
#34 - Kerson Hsiao / @KersonHsiao

08/13/2012 at 09:59AM

32
#35 - Nick Miller / @ItsMeNickMiller

08/13/2012 at 01:51PM

32
#36 - Charles Gordon / @liberalbias

08/22/2012 at 08:50PM

32
#37 - ninjay / @ninjaygolf

08/22/2012 at 09:17PM

32
#38 - Stanislav / @sseletskiy

08/23/2012 at 11:37AM

32
#39 - Alexey Baranov / @baranov0

08/24/2012 at 07:05AM

32
#40 - pixelpurist / @pixelpurist

08/31/2012 at 08:22PM

32
#41 - Augustin Trancart / @autra42

09/06/2012 at 02:48PM

32
#42 - Egor Laufer / @egor_laufer

09/14/2012 at 10:09PM

32
#43 - Conner McDaniel / @connermcd

09/18/2012 at 06:03AM

32
#44 - Lee Folkman / @leefolkman

09/18/2012 at 10:37PM

32
#45 - Nicholas Clark / @GitNick

09/18/2012 at 10:37PM

32
#46 - Victor Ramirez / @virako

09/30/2012 at 10:16PM

32
#47 - Daniel Wallace / @gtmanfred

10/06/2012 at 05:51AM

32
#48 - Vim rocks / @vimrocks

10/08/2012 at 10:17PM

32
#49 - Johan Isacsson / @JohanIsacsson

10/11/2012 at 10:53PM

32
#50 - Kate / @Arohanui

10/23/2012 at 06:43AM

32
#51 - Chris Patuzzo / @cpatuzzo

11/03/2012 at 09:17PM

32
#52 - Alex Podaras / @apodaras

11/07/2012 at 04:35PM

32
#53 - Aniket Schneider / @shaydwyrm

11/17/2012 at 06:58AM

32
#54 - Hubba / @HubbaBubbaFett

11/20/2012 at 08:34AM

32
#55 - Vimgolf Pikob / @vimgolfpikob

11/28/2012 at 12:17AM

32
#56 - Averell Dalton / @webtwoosucks

01/01/2013 at 11:23PM

32
#57 - Terry Ma / @terry_ma

01/06/2013 at 04:12AM

32
#58 - Kurt Robert Rudolph / @krudolph9

01/07/2013 at 12:28AM

32
#59 - Alexander Borysov / @ab99c5e2

01/15/2013 at 06:54PM

32
#60 - Kai Yuan / @kentyuan

02/21/2013 at 12:52PM