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

1365 active golfers, 5551 entries

Leaderboard (lowest score wins):
39
#631 - aRkadeFR / @aRkadeFR

10/03/2013 at 07:01AM

39
#632 - James O Smith / @josmith4242

10/27/2013 at 02:32AM

39
#633 - CarlMartin Rosenberg / @cmrosenberg

11/08/2013 at 01:48AM

39
#634 - evilmoe ☮ / @evilmoe

11/09/2013 at 11:36AM

39
#635 - Ban / @Rheriel

11/11/2013 at 11:42PM

39
#636 - Johan Berg / @_berg85

01/03/2014 at 12:19PM

39
#637 - mattsalacain / @mattsalacain

01/30/2014 at 10:13PM

39
#638 - Mike Marion / @mikejmarion

02/03/2014 at 10:33PM

39
#639 - Michal Keda / @adekcz

04/11/2014 at 10:52AM

39
#640 - Kyle Travis / @kmakai

05/19/2014 at 02:30PM

39
#641 - Dominik Szerszeń / @DominikSze

07/22/2014 at 03:45PM

39
#642 - Matthew Barrington / @mbarrin

07/30/2014 at 10:41PM

39
#643 - Keyboard Fire / @KeyboardFire

11/22/2014 at 02:51PM

39
#644 - Deepak Surti / @dmsurti

03/17/2015 at 01:04PM

39
#645 - Personal Life Trackr / @PersLifeTrackr

05/27/2015 at 09:51PM

39
#646 - Stefan Knudsen / @knud32

06/24/2015 at 02:16AM

39
#647 - Test / @goodbyetest1248

07/24/2015 at 05:15PM

39
#648 - John Clara / @johnanthclara

08/20/2015 at 06:42AM

39
#649 - Paulo Romeira / @pauloromeira

08/26/2015 at 07:22AM

39
#650 - Dian Xiao / @dian_xiao

10/11/2015 at 07:31PM

39
#651 - Oisin Carroll / @oisincar

01/03/2016 at 05:48PM

39
#652 - Luke Warlik / @luke_warlik

03/06/2016 at 06:47PM

39
#653 - Henry Dang / @henrydangchs

05/15/2016 at 03:27AM

39
#654 - Дмитрий Кремез / @dima_kremez

10/23/2016 at 09:53PM

39
#655 - Jon Louie / @jjisnow

12/01/2016 at 03:31AM

39
#656 - Hannu Lounento / @hlounent

12/19/2016 at 06:26PM

39
#657 - J. Cosa / @esoesotracosa

01/18/2017 at 10:13AM

39
#658 - Benedikt Ames / @wisp3rwind

02/08/2017 at 08:19PM

39
#659 - Daniel / @Daniel00288663

03/20/2017 at 11:13AM

39
#660 - BlackCap / @BlackCapCoder

05/24/2017 at 07:25PM