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

1887 active golfers, 7663 entries

Leaderboard (lowest score wins):
32
#91 - chilicuil / @chilicuil

12/27/2013 at 10:56AM

32
#92 - oliver mueller / @marcontwit

01/09/2014 at 09:13PM

32
#93 - alexscott / @4l3xsc0tt

01/15/2014 at 03:45PM

32
#94 - Christian Welle / @welle_tw

01/20/2014 at 09:37PM

32
#95 - Reese Wilson / @shinyvimgolf

02/03/2014 at 05:56AM

32
#96 - grey wolfs / @grey_wolfs

02/03/2014 at 11:31AM

32
#97 - Michael Morgan / @1n1n1s3

02/03/2014 at 06:08PM

32
#98 - Strabs / @artistavenue

02/05/2014 at 10:00AM

32
#99 - Pedro Santos / @pedrosans

02/13/2014 at 10:26PM

32
#100 - Jeremy Gold / @JeremyGold3

02/14/2014 at 08:22AM

32
#101 - Michael Bitzi / @mibitzi

02/14/2014 at 06:28PM

32
#102 - Johannes Schickling / @_schickling

02/14/2014 at 08:32PM

32
#103 - Geraint Hywel / @g_mawr

02/17/2014 at 06:54PM

32
#104 - Thomas GUILLORY / @thomasguillory

02/26/2014 at 01:03PM

32
#105 - Marchand Paul-Valère / @pvmarch

02/26/2014 at 01:05PM

32
#106 - John Braxler / @braxler

03/13/2014 at 09:38PM

32
#107 - Yiyang Chen / @stackngxc

03/16/2014 at 01:33PM

32
#108 - Isaac / @elemental_1_1

03/23/2014 at 08:38AM

32
#109 - Akshay Hegde / @ajh_17

04/17/2014 at 06:11AM

32
#110 - kiho choi / @ArtStandAlone

04/24/2014 at 11:07AM

32
#111 - Utkarsh Kukreti / @utkarshkukreti

05/03/2014 at 08:44PM

32
#112 - zmo / @guyzmo

05/10/2014 at 04:30PM

32
#113 - Steffen Siering / @ursobln

06/04/2014 at 09:18PM

32
#114 - Robert Bruce / @therealrobru

06/10/2014 at 11:25PM

32
#115 - Mayor Guelph / @RogerGuelph

06/19/2014 at 03:15AM

32
#116 - John Meisner / @jmeisned

06/24/2014 at 08:09PM

32
#117 - Ben Haines / @bhainesva

08/07/2014 at 07:42PM

32
#118 - Aaron Fresh / @AaronFresh7

09/13/2014 at 08:44AM

32
#119 - Michael Comerford / @MComerford1

09/21/2014 at 01:11AM

32
#120 - @sndsgns / @sndsgns

10/25/2014 at 08:06PM