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

1321 active golfers, 5391 entries

Leaderboard (lowest score wins):
36
#421 - Carl Egbert / @CarlOEgbert

06/09/2017 at 09:36PM

36
#422 - Bennett Bernardoni / @BBernardoni

06/28/2017 at 07:32PM

36
#423 - Matti Sairanen / @MattiSairanen

08/03/2017 at 11:28AM

36
#424 - しぇぱっち / @shepabashi

10/23/2017 at 05:58AM

36
#425 - BareTull / @BareTull3

12/04/2017 at 01:37PM

36
#426 - tPenguinLTG / @tpenguinltg

01/16/2018 at 04:51PM

36
#427 - DHM / @DHM29978992

04/13/2018 at 02:37AM

36
#428 - Brendan B Amdocs / @AmdocsB

09/28/2018 at 04:08PM

36
#429 - Roger Bongers / @RogerBongers

10/06/2018 at 05:41PM

37
#430 - Sérgio Figueiredo / @doubl3dge

12/30/2010 at 02:42PM

37
#431 - Alain Gilbert / @alain_gilbert

12/30/2010 at 11:17PM

37
#432 - kmymtksh / @kmymtksh

12/31/2010 at 07:55PM

37
#433 - Marc Lacoursière / @RooSoft

01/05/2011 at 12:07AM

37
#434 - dominique pellé / @vimgolfisto

01/06/2011 at 10:39PM

37
#435 - Sam / @samng96

01/07/2011 at 01:04AM

37
#436 - Douglas Stockwell / @dstockwell

01/08/2011 at 08:34PM

37
#437 - Rörd Hinrichsen / @roerdhh

01/09/2011 at 09:46PM

37
#438 - Toto l'haricot / @nico_le_terribl

01/10/2011 at 10:20PM

37
#439 - Stephen Morrow / @yawmark

01/13/2011 at 03:40AM

37
#440 - deris / @deris0126

01/26/2011 at 05:40PM

37
#441 - Luke Randall / @luke_randall

02/08/2011 at 03:30PM

37
#442 - Tim Harper / @timcharper

03/17/2011 at 07:58PM

37
#443 - Yannis Chatzimichos / @feedward

04/13/2011 at 12:57AM

37
#444 - Damian Dawber / @damian6970

05/30/2011 at 08:46PM

37
#445 - Alan Peabody / @alanpeabody

06/03/2011 at 03:31AM

37
#446 - rhkwdamicjhdf / @rhkwdamicjhdf

06/08/2011 at 06:02AM

37
#447 - Peter Anselmo / @peter_anselmo

06/24/2011 at 08:59PM

37
#448 - Eric Gerlach / @egerlach

07/17/2011 at 05:42AM

37
#449 - Neil / @spameldoon

08/20/2011 at 11:37PM

37
#450 - Carlos Yaconi H. / @cyaconi

12/06/2011 at 03:19PM