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

1346 active golfers, 5485 entries

Leaderboard (lowest score wins):
35
#301 - Paul Bourke / @brk3

12/13/2011 at 02:52PM

35
#302 - Sergio Benitez / @Sergio965

01/30/2012 at 06:50PM

35
#303 - Aaron Spiegel / @spiegela

02/05/2012 at 01:36AM

35
#304 - snuffling / @snuffling

02/12/2012 at 08:58PM

35
#305 - フルメキ / @hurumeki

03/24/2012 at 12:48AM

35
#306 - Einar Jónsson / @einarj

03/30/2012 at 03:58PM

35
#307 - Rubén Laguna / @ecerulm

04/21/2012 at 07:45AM

35
#308 - Rodrigo Ayala / @RodrigoAyala

05/15/2012 at 05:49PM

35
#309 - OMF / @exolon

05/25/2012 at 10:45PM

35
#310 - shark dick / @DickShark

07/12/2012 at 09:10PM

35
#311 - wes / @_weslly

07/16/2012 at 03:20PM

35
#312 - Dan Oneata / @DanOneata

08/04/2012 at 04:32PM

35
#313 - vansan / @VinceVansan

08/23/2012 at 11:22AM

35
#314 - Mats Sigge / @MatsSigge

09/29/2012 at 10:11AM

35
#315 - Tamás Kárándi / @tkarandi

12/02/2012 at 08:57PM

35
#316 - kaorimatz / @kaorimatz

12/22/2012 at 03:39AM

35
#317 - Kuldeep Bora / @kuldeep_bora

04/17/2013 at 07:57AM

35
#318 - Eric Potter / @pottereric

06/05/2013 at 04:33PM

35
#319 - Arthur LEDARD / @arthur_yaal

06/27/2013 at 04:49PM

35
#320 - RobertT / @techrt2050

07/11/2013 at 10:21AM

35
#321 - Roland Schatz / @fl_Overmind

07/12/2013 at 02:54PM

35
#322 - Armand Halbert / @armandhalbert

08/16/2013 at 08:46PM

35
#323 - Colin Garriga-Salaün / @cgarrigasalaun

09/26/2013 at 07:25PM

35
#324 - atemeresclencare / @kfzhyzdj

09/30/2013 at 06:52AM

35
#325 - omonsaboliturisl / @rarylverwaffelp

09/30/2013 at 07:08AM

35
#326 - gary.klindt@googlema / @garstekli

11/12/2013 at 06:43PM

35
#327 - Fake Name / @The_Real_User

01/07/2014 at 03:38AM

35
#328 - Quota / @Quotad

01/10/2014 at 01:29PM

35
#329 - Arsenic Hall / @FoxLisk

01/28/2014 at 11:58PM

35
#330 - JamesT / @jamestrinklein

01/29/2014 at 09:15AM