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

1891 active golfers, 7688 entries

Leaderboard (lowest score wins):
35
#421 - vimgolfer220902 / @vimgolfer220902

09/02/2022 at 02:52PM

35
#422 - かみひろ / @km_hr

02/04/2023 at 05:29AM

35
#423 - Chris Atanasian / @chrisatanasian

11/16/2023 at 06:28PM

35
#424 - Eugene Mondkar / @EugeneMondkar

05/06/2024 at 01:51AM

35
#425 - Paul Molloy / @paulsmolloy

05/09/2024 at 01:47PM

35
#426 - Aly Thobani / @alythobani

05/28/2024 at 12:42AM

35
#427 - Don'tBeAlarmed / @DontBeAlarmed

05/31/2024 at 06:16PM

35
#428 - glibg10b / @glibg10b

11/18/2024 at 12:56PM

35
#429 - Nathan Priego / @nspriego

02/19/2025 at 05:19AM

35
#430 - raylmorris / @raylmorris

07/05/2025 at 04:05AM

35
#431 - dnzc / @dnzc

08/29/2025 at 11:12PM

35
#432 - mohaoz / @mohaoz

11/08/2025 at 04:31PM

35
#433 - jakharsh26 / @jakharsh26

02/24/2026 at 01:36PM

36
#434 - Kerry Buckley / @kerryb

12/29/2010 at 07:55AM

36
#435 - kana / @kana1

12/29/2010 at 04:30PM

36
#436 - Akira Matsuda / @a_matsuda

12/30/2010 at 02:05AM

36
#437 - Scott Abernethy / @scott_abernethy

12/31/2010 at 03:41AM

36
#438 - Behnam Esfahbod / @zwnj

12/31/2010 at 03:01PM

36
#439 - Matthew Draper / @_matthewd

01/06/2011 at 05:53AM

36
#440 - Tim Chase / @gumnos

01/08/2011 at 03:14PM

36
#441 - Pete Johns / @johnsyweb

01/14/2011 at 09:25PM

36
#442 - Anders Janmyr / @andersjanmyr

01/16/2011 at 03:06PM

36
#443 - Jed Hurt / @meekish

02/05/2011 at 05:44AM

36
#444 - Arthur Chiu / @arthur_chiu

02/06/2011 at 02:09AM

36
#445 - Pavlo Klets / @p01nt

02/06/2011 at 07:11PM

36
#446 - Derrick Camerino / @robustdj

04/21/2011 at 02:10AM

36
#447 - Terje Larsen / @terlars

05/09/2011 at 01:16PM

36
#448 - Charles Max Wood / @cmaxw

05/24/2011 at 10:27PM

36
#449 - icdark / @icdark

05/29/2011 at 09:41PM

36
#450 - Eric Stewart / @ericstewart

05/30/2011 at 05:26AM