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

1486 active golfers, 6033 entries

Leaderboard (lowest score wins):
39
#691 - Anne Pacalet / @_Anne_P

07/25/2017 at 11:36AM

39
#692 - xyz / @menhej

02/04/2018 at 12:41AM

39
#693 - Fabio Branquinho / @branquif

11/08/2018 at 08:59PM

39
#694 - phoibos92@gmail.com / @phoibos92

11/13/2018 at 03:52PM

39
#695 - Dax / @zacoxi

11/20/2018 at 03:09AM

39
#696 - Performa / @performa6400

11/29/2018 at 04:53PM

39
#697 - Mateen Ulhaq / @sicariusnoctis

02/12/2019 at 08:59AM

39
#698 - serent / @serent

04/22/2019 at 07:15PM

39
#699 - Peter Demin / @peterdemin

07/11/2019 at 06:42PM

39
#700 - Neil Struthers / @struthersneil

07/18/2019 at 10:26PM

39
#701 - Miko / @_m_ik_o_

10/06/2019 at 01:52PM

39
#702 - 황진우 / @dhy04063

05/11/2020 at 06:27AM

39
#703 - iBhagwan / @iiBhagwan

05/11/2020 at 11:44PM

39
#704 - せいほう / @FICSQF

06/29/2020 at 04:04AM

39
#705 - Ming Dai / @MingDai2

06/30/2020 at 04:36PM

39
#706 - drumstix576 / @drumstix576

11/20/2020 at 07:22PM

39
#707 - Ray Dennis / @raysden

01/08/2021 at 05:52PM

39
#708 - Filipe Brandenburger / @filbranden

05/28/2021 at 04:11PM

39
#709 - Patrick Gates / @patrickgates

06/14/2021 at 11:25PM

39
#710 - Adam / @Adam75625825

06/29/2021 at 03:51PM

39
#711 - Sean Cahill / @ess_jay_kay

10/26/2021 at 04:53PM

39
#712 - shahanavaz m / @shahanavazm

04/02/2022 at 02:50AM

39
#713 - unchi / @unchi10723002

05/07/2022 at 06:44AM

39
#714 - quemeraisc / @quemeraisc

05/19/2022 at 03:34PM

40
#715 - Brad Grzesiak / @listrophy

12/28/2010 at 08:10PM

40
#716 - David Shaw / @shawthings

12/30/2010 at 10:18AM

40
#717 - Fitz / @Fitzface

12/31/2010 at 03:11PM

40
#718 - Roman Mašek / @romario333

01/02/2011 at 06:16PM

40
#719 - Grigoriy Glushko / @grinderrz

01/05/2011 at 12:36PM

40
#720 - aimee / @sermoa

01/08/2011 at 02:21PM