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

1456 active golfers, 5889 entries

Leaderboard (lowest score wins):
35
#331 - Armand Halbert / @armandhalbert

08/16/2013 at 08:46PM

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

09/26/2013 at 07:25PM

35
#333 - atemeresclencare / @kfzhyzdj

09/30/2013 at 06:52AM

35
#334 - omonsaboliturisl / @rarylverwaffelp

09/30/2013 at 07:08AM

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

11/12/2013 at 06:43PM

35
#336 - Fake Name / @The_Real_User

01/07/2014 at 03:38AM

35
#337 - Quota / @Quotad

01/10/2014 at 01:29PM

35
#338 - Arsenic Hall / @FoxLisk

01/28/2014 at 11:58PM

35
#339 - JamesT / @jamestrinklein

01/29/2014 at 09:15AM

35
#340 - Yongho / @YONG_HO

02/06/2014 at 10:17AM

35
#341 - Joonas Pihlajamaa / @jokkebk

02/08/2014 at 11:26PM

35
#342 - Hannes Remahl / @hannesr

02/27/2014 at 04:17PM

35
#343 - William Snyders / @iam2391212

03/05/2014 at 12:10AM

35
#344 - Norm Fasey / @DeathRay1977

05/02/2014 at 09:13PM

35
#345 - Mauro Persano / @fzort

11/16/2014 at 10:19AM

35
#346 - Test User / @TestUserIgnore

12/04/2014 at 11:22PM

35
#347 - David Han / @HanDavid

12/07/2014 at 04:03AM

35
#348 - Sntano Euhsk / @SEuhsk

01/15/2015 at 11:21PM

35
#349 - TheProgrammer971 / @tp971

03/14/2015 at 02:22AM

35
#350 - Faat / @i_faat

01/29/2016 at 01:45PM

35
#351 - James Burns / @James_Ian_Burns

02/21/2016 at 02:54PM

35
#352 - Yahyalexandre33 / @yahyalexandre33

03/15/2016 at 07:57AM

35
#353 - S O / @strangelooperer

04/17/2016 at 09:04PM

35
#354 - Håkon Bråten / @h_braten

04/26/2016 at 03:52PM

35
#355 - Andres Araya / @arayaandresfco

05/15/2016 at 07:41PM

35
#356 - (,,꒪꒫꒪,,) / @sneer

05/22/2016 at 07:38AM

35
#357 - Jan Bundesmann / @janbundesmann

05/31/2016 at 12:44PM

35
#358 - Reuben Huxley / @missiontocode

06/29/2016 at 09:51PM

35
#359 - TweetDreams / @TweetMusicians

10/08/2016 at 10:16PM

35
#360 - Benoit Mortgat / @Benoit_Mortgat

11/14/2017 at 10:49AM