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

1754 active golfers, 7154 entries

Leaderboard (lowest score wins):
32
#31 - Augustin Trancart / @autra42

09/06/2012 at 02:48PM

32
#32 - Egor Laufer / @egor_laufer

09/14/2012 at 10:09PM

32
#33 - Conner McDaniel / @connermcd

09/18/2012 at 06:03AM

32
#34 - Lee Folkman / @leefolkman

09/18/2012 at 10:37PM

32
#35 - Nicholas Clark / @GitNick

09/18/2012 at 10:37PM

32
#36 - Victor Ramirez / @virako

09/30/2012 at 10:16PM

32
#37 - Daniel Wallace / @gtmanfred

10/06/2012 at 05:51AM

32
#38 - Vim rocks / @vimrocks

10/08/2012 at 10:17PM

32
#39 - Johan Isacsson / @JohanIsacsson

10/11/2012 at 10:53PM

32
#40 - Kate / @Arohanui

10/23/2012 at 06:43AM

32
#41 - Chris Patuzzo / @cpatuzzo

11/03/2012 at 09:17PM

32
#42 - Alex Podaras / @apodaras

11/07/2012 at 04:35PM

32
#43 - Aniket Schneider / @shaydwyrm

11/17/2012 at 06:58AM

32
#44 - Hubba / @HubbaBubbaFett

11/20/2012 at 08:34AM

32
#45 - Vimgolf Pikob / @vimgolfpikob

11/28/2012 at 12:17AM

32
#46 - Averell Dalton / @webtwoosucks

01/01/2013 at 11:23PM

32
#47 - Terry Ma / @terry_ma

01/06/2013 at 04:12AM

32
#48 - Kurt Robert Rudolph / @krudolph9

01/07/2013 at 12:28AM

32
#49 - Alexander Borysov / @ab99c5e2

01/15/2013 at 06:54PM

32
#50 - Kai Yuan / @kentyuan

02/21/2013 at 12:52PM

32
#51 - igoodrich / @igoodrich

03/02/2013 at 06:30AM

32
#52 - Nikolaj / @n1k0laj

03/14/2013 at 09:25AM

32
#53 - Petro Тrouq / @zulolosi

03/25/2013 at 11:21PM

32
#54 - Robottinosino / @Robottinosino

05/18/2013 at 06:52AM

32
#55 - 张文远 / @zhwenyuan

05/21/2013 at 01:34PM

32
#56 - Ingo / @ist3fani

06/01/2013 at 03:38PM

32
#57 - Adam Pohorecki / @apohorecki

06/12/2013 at 10:57AM

32
#58 - Jonáš Šerých / @serycjon

06/25/2013 at 09:58PM

32
#59 - Łukasz Bujakowski / @eggxtreme

06/28/2013 at 04:34PM

32
#60 - Eric Alexander / @ericalexander

07/10/2013 at 02:12AM