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

1369 active golfers, 5569 entries

Leaderboard (lowest score wins):
36
#391 - Aaron Hall / @aarontothemax

08/27/2012 at 01:35AM

36
#392 - Mikko Loponen / @lopossumi

11/02/2012 at 02:32PM

36
#393 - Echosa / @echosa

12/13/2012 at 11:59PM

36
#394 - Xinruo Sun / @xiaoruoruo

12/23/2012 at 12:43PM

36
#395 - Ben / @ben_g_thomas

01/09/2013 at 09:48PM

36
#396 - Claes Mogren / @claesmogren

03/19/2013 at 06:47AM

36
#397 - gnobbles / @gnobbles

03/30/2013 at 08:56PM

36
#398 - Tyler / @tylerbindon

03/31/2013 at 01:44AM

36
#399 - jeepee / @jeepee_test

06/10/2013 at 12:28PM

36
#400 - powertomato / @powertomato

06/27/2013 at 10:41PM

36
#401 - Timothée Gauthier / @zmf_tim

07/04/2013 at 08:58PM

36
#402 - brett / @brettyukich

09/18/2013 at 09:33PM

36
#403 - Rafael Rendon Pablo / @__rendon__

12/15/2013 at 03:01AM

36
#404 - John Karlsson / @karlssonjohn

01/28/2014 at 08:58PM

36
#405 - Jérémy Autran / @jjautran

01/29/2014 at 08:45PM

36
#406 - Zudov / @zudov_me

02/04/2014 at 07:36PM

36
#407 - Bart Nagel / @bjnagel

02/20/2014 at 09:27AM

36
#408 - フミ ハシ / @fumi_hs

02/21/2014 at 02:28PM

36
#409 - sprmgik / @sprmgik

03/14/2014 at 03:09AM

36
#410 - God / @iamgod

03/25/2014 at 01:55PM

36
#411 - Jeff / @just_geophree

03/29/2014 at 09:22PM

36
#412 - onthos / @onthos_

04/25/2014 at 10:47AM

36
#413 - Shawn / @ShawnSquire

06/05/2014 at 06:09PM

36
#414 - Caek / @Caek_

08/12/2014 at 04:42AM

36
#415 - w1zeman1p / @wizemanip

11/09/2014 at 08:01PM

36
#416 - Charles Joachim / @cacplate

04/19/2015 at 10:15PM

36
#417 - Roben Kleene / @robenkleene

07/31/2015 at 12:59AM

36
#418 - John Diamond / @jcdmnd

08/14/2015 at 03:43PM

36
#419 - Nicolas Nistal / @niconistal

11/19/2015 at 12:44AM

36
#420 - Alex Ch / @_AlexCh_

03/31/2016 at 10:35PM