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):
34
#271 - BZ_VG / @BZ_VG

11/12/2012 at 09:47AM

34
#272 - Adelar S. Queiróz / @adelarsq

11/28/2012 at 01:03AM

34
#273 - Jonas Engman / @jodas

02/18/2013 at 02:43PM

34
#274 - Ben / @bdchauvette

05/03/2013 at 07:48AM

34
#275 - Booberius / @booberius

05/29/2013 at 04:31PM

34
#276 - Christopher Bahr / @bahrware

07/11/2013 at 04:59AM

34
#277 - Elias Dorneles / @eliasdorneles

09/03/2013 at 04:46AM

34
#278 - Matt Green / @emgeeeeee

09/15/2013 at 03:44AM

34
#279 - Forrest Zeisler / @fzeisler

11/08/2013 at 02:07AM

34
#280 - Jacob Niehus / @wilywampa

12/18/2013 at 07:14AM

34
#281 - Bradford Powell / @dr_bpow

12/23/2013 at 08:45PM

34
#282 - Võ Duy Vinh / @VoDuyVinh

02/23/2014 at 01:38AM

34
#283 - Antonio Jesús / @antoniojesvs

02/27/2014 at 02:54PM

34
#284 - Jonas Arnold Clasen / @jonasclasen

06/08/2014 at 08:43PM

34
#285 - playalong / @playwithit42

07/08/2014 at 11:18AM

34
#286 - Tomasz Wesołowski / @KosGD

10/13/2014 at 07:47PM

34
#287 - Matthieu Crapet / @mcr05

12/05/2014 at 09:40PM

34
#288 - Josu Oyanguren / @josuoyanguren

12/22/2014 at 08:49AM

34
#289 - Skúli Jóhannsson / @skulibj

06/26/2015 at 02:15PM

34
#290 - retro / @tryphopp

01/10/2016 at 08:29AM

34
#291 - Thijs van den Anker / @thijsvdanker

02/15/2016 at 08:48AM

34
#292 - Bradley M. Small / @BradleySmall

11/20/2017 at 01:56PM

35
#293 - uuu / @uu59

12/30/2010 at 12:41AM

35
#294 - jacobangel / @jacobangel

12/31/2010 at 07:09AM

35
#295 - duckdalbe / @duckdalbe

01/14/2011 at 11:47AM

35
#296 - h_east (トロッコ6個) / @h_east

01/17/2011 at 12:59AM

35
#297 - Antony Scriven / @antonyscriven

02/05/2011 at 08:23PM

35
#298 - Mark Scholtz / @markscholtz

02/07/2011 at 08:17PM

35
#299 - David / @dpa_92

08/01/2011 at 09:09AM

35
#300 - William Dunand / @wdunand

12/13/2011 at 05:50AM