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

1850 active golfers, 7514 entries

Leaderboard (lowest score wins):
36
#481 - John Diamond / @jcdmnd

08/14/2015 at 03:43PM

36
#482 - Nicolas Nistal / @niconistal

11/19/2015 at 12:44AM

36
#483 - Alex Ch / @_AlexCh_

03/31/2016 at 10:35PM

36
#484 - Atrament / @Atrament

05/11/2016 at 03:25PM

36
#485 - Mateusz / @Mantos77

09/05/2016 at 12:34AM

36
#486 - Carl Egbert / @CarlOEgbert

06/09/2017 at 09:36PM

36
#487 - Bennett Bernardoni / @BBernardoni

06/28/2017 at 07:32PM

36
#488 - Matti Sairanen / @MattiSairanen

08/03/2017 at 11:28AM

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

10/23/2017 at 05:58AM

36
#490 - BareTull / @BareTull3

12/04/2017 at 01:37PM

36
#491 - tPenguinLTG / @tpenguinltg

01/16/2018 at 04:51PM

36
#492 - DHM / @DHM29978992

04/13/2018 at 02:37AM

36
#493 - Brendan B Amdocs / @AmdocsB

09/28/2018 at 04:08PM

36
#494 - Roger Bongers / @RogerBongers

10/06/2018 at 05:41PM

36
#495 - Martin Delille / @martinodelilo

08/24/2019 at 01:49PM

36
#496 - howanto / @ho_wan_

02/23/2020 at 01:34PM

36
#497 - Martin Bielik / @mabielik

09/06/2020 at 09:25PM

36
#498 - lamtt77 / @lamtt77

10/11/2020 at 07:28AM

36
#499 - Vahan / @Vahan00900245

10/07/2021 at 04:09PM

36
#500 - Golf Vim / @GolfVim11388

06/30/2023 at 01:15PM

36
#501 - emre özküçük / @emreozkucuk

11/13/2023 at 07:51PM

36
#502 - shahanavaz m / @shahanavazm

01/31/2024 at 09:35PM

36
#503 - schrjako / @schrjako

04/06/2024 at 10:00AM

36
#504 - ck961018 / @ck961018

05/04/2024 at 05:22AM

36
#505 - ^M\w{3}$ / @Frankva

07/18/2024 at 12:01PM

36
#506 - xscript71 / @xscript71

10/14/2024 at 12:46PM

36
#507 - Anton de Regt / @antonderegt

10/24/2024 at 06:57PM

36
#508 - whjum / @whjum

01/14/2025 at 03:19AM

36
#509 - Connor Murphy / @contrick64

06/25/2025 at 08:19PM

36
#510 - adityakamath255 / @adityakamath255

11/21/2025 at 04:26PM