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

1366 active golfers, 5560 entries

Leaderboard (lowest score wins):
39
#661 - Anne Pacalet / @_Anne_P

07/25/2017 at 11:36AM

39
#662 - xyz / @menhej

02/04/2018 at 12:41AM

39
#663 - Fabio Branquinho / @branquif

11/08/2018 at 08:59PM

39
#664 - phoibos92@gmail.com / @phoibos92

11/13/2018 at 03:52PM

39
#665 - Dax / @zacoxi

11/20/2018 at 03:09AM

39
#666 - Performa / @performa6400

11/29/2018 at 04:53PM

39
#667 - Mateen Ulhaq / @sicariusnoctis

02/12/2019 at 08:59AM

39
#668 - serent / @serent

04/22/2019 at 07:15PM

39
#669 - Peter Demin / @peterdemin

07/11/2019 at 06:42PM

39
#670 - Neil Struthers / @struthersneil

07/18/2019 at 10:26PM

39
#671 - Miko / @_m_ik_o_

10/06/2019 at 01:52PM

40
#672 - Brad Grzesiak / @listrophy

12/28/2010 at 08:10PM

40
#673 - David Shaw / @shawthings

12/30/2010 at 10:18AM

40
#674 - Fitz / @Fitzface

12/31/2010 at 03:11PM

40
#675 - Roman MaĊĦek / @romario333

01/02/2011 at 06:16PM

40
#676 - Grigoriy Glushko / @grinderrz

01/05/2011 at 12:36PM

40
#677 - aimee / @sermoa

01/08/2011 at 02:21PM

40
#678 - James Edward Gray II / @JEG2

04/04/2011 at 12:56AM

40
#679 - Shawn / @sartak

04/22/2011 at 10:50PM

40
#680 - Lauri Tirkkonen / @lotheac

07/01/2011 at 11:17PM

40
#681 - Kubek2k / @kubek2k

09/29/2011 at 10:33PM

40
#682 - johan wester / @wester87

11/12/2011 at 04:27PM

40
#683 - Travis Jeffery / @travisjeffery

12/07/2011 at 12:25AM

40
#684 - Kristopher Urie / @kristopherurie

02/09/2012 at 02:39AM

40
#685 - Vijay Dev / @vijay_dev

02/13/2012 at 09:42AM

40
#686 - Nolen Royalty / @NolenRoyalty

04/20/2012 at 08:30PM

40
#687 - francois bard / @misterfrb

05/04/2012 at 08:53AM

40
#688 - tmr / @tmr314

09/06/2012 at 03:50PM

40
#689 - Andrea Francia / @andreafrancia

10/05/2012 at 07:34PM

40
#690 - Ole Petter Bang / @gnab

10/21/2012 at 08:38PM