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):
32
#91 - Johannes Schickling / @_schickling

02/14/2014 at 08:32PM

32
#92 - Geraint Hywel / @g_mawr

02/17/2014 at 06:54PM

32
#93 - Thomas GUILLORY / @thomasguillory

02/26/2014 at 01:03PM

32
#94 - Marchand Paul-Valère / @pvmarch

02/26/2014 at 01:05PM

32
#95 - John Braxler / @braxler

03/13/2014 at 09:38PM

32
#96 - Yiyang Chen / @yiyangc91

03/16/2014 at 01:33PM

32
#97 - Isaac / @elemental_1_1

03/23/2014 at 08:38AM

32
#98 - Akshay Hegde / @ajh_17

04/17/2014 at 06:11AM

32
#99 - kiho choi / @ArtStandAlone

04/24/2014 at 11:07AM

32
#100 - Utkarsh Kukreti / @utkarshkukreti

05/03/2014 at 08:44PM

32
#101 - zmo / @guyzmo

05/10/2014 at 04:30PM

32
#102 - Steffen Siering / @ursobln

06/04/2014 at 09:18PM

32
#103 - Robert Bruce / @therealrobru

06/10/2014 at 11:25PM

32
#104 - Mayor Guelph / @RogerGuelph

06/19/2014 at 03:15AM

32
#105 - John Meisner / @jmeisned

06/24/2014 at 08:09PM

32
#106 - Ben Haines / @bhainesva

08/07/2014 at 07:42PM

32
#107 - Aaron Fresh / @AaronFresh7

09/13/2014 at 08:44AM

32
#108 - Michael Comerford / @MComerford1

09/21/2014 at 01:11AM

32
#109 - @sndsgns / @sndsgns

10/25/2014 at 08:06PM

32
#110 - Ivan Brennan / @ivanbrennan

12/02/2014 at 03:44AM

32
#111 - Bellator nobilis / @BNobilis

12/21/2014 at 10:55PM

32
#112 - Zull Full / @Zullfull

01/11/2015 at 04:36PM

32
#113 - kimber gonzalez / @kimberlycreates

01/12/2015 at 07:55PM

32
#114 - mark0829 / @mark0829

01/30/2015 at 08:35AM

32
#115 - xieyh11 / @xieyh11

02/17/2015 at 04:28AM

32
#116 - Michael Giuffrida / @mgiuffrida

02/24/2015 at 04:34AM

32
#117 - DrHobo / @_DrHobo_

03/14/2015 at 05:06PM

32
#118 - pftb12345 / @pftb12345

03/31/2015 at 02:16PM

32
#119 - Ferdev vimgolf / @fergvimgolf

08/10/2015 at 02:37AM

32
#120 - Peter B / @l0wm4x

08/12/2015 at 06:42PM