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

1882 active golfers, 7649 entries

Leaderboard (lowest score wins):
32
#181 - Andreas Näsman / @andreas_nasman

06/17/2022 at 10:41AM

32
#182 - Александр Моисеев / @Aleksan43607471

01/19/2023 at 10:37AM

32
#183 - QKSDM / @qksdm

02/01/2024 at 06:54PM

32
#184 - Simo Kivistö / @kivissimo

02/05/2024 at 08:04PM

32
#185 - Petro Mudrievskyj / @petemud

06/27/2024 at 09:09AM

32
#186 - Peppa Pig / @PeppaPigSg

09/13/2024 at 02:42AM

32
#187 - Alexander Ivanov / @karamfil

11/27/2024 at 08:55PM

32
#188 - kooxn / @kooxn

05/11/2025 at 06:02AM

32
#189 - Vsevolod Rychkov / @MadPigeon

07/15/2025 at 02:11PM

32
#190 - adiantum / @adiantum-studio

12/09/2025 at 02:32PM

32
#191 - donghwanjin / @donghwanjin

12/13/2025 at 10:20AM

32
#192 - eastaveracruz / @eastaveracruz

07/08/2026 at 04:50PM

33
#193 - iCross / @iCrossOfficial

02/01/2011 at 04:52PM

33
#194 - Joost / @vlabakje

02/20/2011 at 01:17PM

33
#195 - Sergey Doroshenko / @dorserg

03/04/2011 at 07:48AM

33
#196 - Ruy Diaz / @diazruy

03/08/2011 at 06:20PM

33
#197 - Paweu1kZ nbNeyIhH / @yUQlwsFpRSzxJFh

03/09/2011 at 07:22AM

33
#198 - Aaron Jensen / @aaronjensen

03/18/2011 at 06:00AM

33
#199 - Mikael Gustavsson / @slvmnd

04/19/2011 at 02:53PM

33
#200 - こばばー / @symmet

04/24/2011 at 09:05AM

33
#201 - kjrn / @kjrnleto

05/20/2011 at 07:27PM

33
#202 - Emile Swarts / @EmileSwarts

05/29/2011 at 11:38AM

33
#203 - Justin Love / @wondible

06/03/2011 at 12:18PM

33
#204 - Black Wolf / @LoboVimGolf

06/15/2011 at 09:24AM

33
#205 - Rolf Bjaanes / @rolfb

06/15/2011 at 06:58PM

33
#206 - Jonathan / @saysjonathan

07/01/2011 at 01:21AM

33
#207 - Junfeng / @junfeng

07/13/2011 at 11:52AM

33
#208 - Carlo Biedenharn / @Carlohedron

07/15/2011 at 09:46PM

33
#209 - ineb / @ineb0

08/14/2011 at 02:57PM

33
#210 - Emeric Dupont / @stucule

08/22/2011 at 12:50PM