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

1398 active golfers, 5692 entries

Leaderboard (lowest score wins):
37
#511 - John Oleksowicz / @JohnOlek

10/09/2018 at 07:56PM

37
#512 - name / @name65894813

11/16/2018 at 04:44PM

37
#513 - hbdgr / @t_hbdgr

01/26/2019 at 08:07PM

37
#514 - 默罕默德 / @Rt6RjEAJ987Woes

02/20/2019 at 03:21AM

37
#515 - wanghbxxxx / @wanghbxxxx

04/07/2019 at 01:27PM

37
#516 - james_bunch / @james_bunch

04/20/2019 at 05:58AM

37
#517 - お薬手帳 / @iW4Wz6PpCiqyGqH

04/24/2019 at 05:54AM

37
#518 - Miłosz Łakomy / @foobar01123

07/08/2019 at 09:41AM

37
#519 - Vladimir Leskov / @vladimirlesk

10/12/2019 at 12:01PM

37
#520 - BnnGolfer / @BnnGolfer

03/31/2020 at 06:49PM

37
#521 - Valdimar / @genkobar

06/08/2020 at 10:35PM

38
#522 - Samus_ Michael / @gonna_hate

12/29/2010 at 02:40AM

38
#523 - Henri Bourcereau / @mmai

12/29/2010 at 11:41AM

38
#524 - Takayuki Tsukitani / @tsukkee

12/30/2010 at 07:27AM

38
#525 - Vincent Isambart / @vincentisambart

12/31/2010 at 01:14PM

38
#526 - wyl rof / @wylrof

01/02/2011 at 10:49AM

38
#527 - Brian Buckley / @bbuckley

01/20/2011 at 11:58AM

38
#528 - Grai / @haybeesea

02/16/2011 at 04:11AM

38
#529 - Eivind Jahren / @HaskellElephant

02/22/2011 at 08:39PM

38
#530 - Avinash Baliga / @avinashbaliga

03/24/2011 at 06:30AM

38
#531 - mightyfoo / @mightyfoo

05/25/2011 at 10:27AM

38
#532 - dtennant / @dtennant

06/01/2011 at 06:29PM

38
#533 - drooooooooooo / @droooooooooooo

08/01/2011 at 03:43AM

38
#534 - Sergey Kim / @skim1776

08/21/2011 at 07:21PM

38
#535 - jasper110 / @jasper110

09/21/2011 at 04:05PM

38
#536 - Martin Janiczek / @janiczek

10/14/2011 at 06:49PM

38
#537 - changling / @Lspacewalker

12/15/2011 at 09:06PM

38
#538 - sutringonavira / @sutringonavira

01/13/2012 at 08:57PM

38
#539 - Hannu Kröger / @hkroger

01/18/2012 at 10:33PM

38
#540 - Marcin Górnik / @gornikm

01/30/2012 at 08:25PM