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

1398 active golfers, 5692 entries

Leaderboard (lowest score wins):
39
#661 - Oisin Carroll / @oisincar

01/03/2016 at 05:48PM

39
#662 - Luke Warlik / @luke_warlik

03/06/2016 at 06:47PM

39
#663 - Henry Dang / @henrydangchs

05/15/2016 at 03:27AM

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

10/23/2016 at 09:53PM

39
#665 - Jon Louie / @jjisnow

12/01/2016 at 03:31AM

39
#666 - Hannu Lounento / @hlounent

12/19/2016 at 06:26PM

39
#667 - J. Cosa / @esoesotracosa

01/18/2017 at 10:13AM

39
#668 - Benedikt Ames / @wisp3rwind

02/08/2017 at 08:19PM

39
#669 - Daniel / @Daniel00288663

03/20/2017 at 11:13AM

39
#670 - BlackCap / @BlackCapCoder

05/24/2017 at 07:25PM

39
#671 - Anne Pacalet / @_Anne_P

07/25/2017 at 11:36AM

39
#672 - xyz / @menhej

02/04/2018 at 12:41AM

39
#673 - Fabio Branquinho / @branquif

11/08/2018 at 08:59PM

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

11/13/2018 at 03:52PM

39
#675 - Dax / @zacoxi

11/20/2018 at 03:09AM

39
#676 - Performa / @performa6400

11/29/2018 at 04:53PM

39
#677 - Mateen Ulhaq / @sicariusnoctis

02/12/2019 at 08:59AM

39
#678 - serent / @serent

04/22/2019 at 07:15PM

39
#679 - Peter Demin / @peterdemin

07/11/2019 at 06:42PM

39
#680 - Neil Struthers / @struthersneil

07/18/2019 at 10:26PM

39
#681 - Miko / @_m_ik_o_

10/06/2019 at 01:52PM

39
#682 - 황진우 / @dhy04063

05/11/2020 at 06:27AM

39
#683 - Bhagwan / @El_Bhagwan

05/11/2020 at 11:44PM

39
#684 - せいほう / @FICSQF

06/29/2020 at 04:04AM

39
#685 - Ming Dai / @MingDai2

06/30/2020 at 04:36PM

40
#686 - Brad Grzesiak / @listrophy

12/28/2010 at 08:10PM

40
#687 - David Shaw / @shawthings

12/30/2010 at 10:18AM

40
#688 - Fitz / @Fitzface

12/31/2010 at 03:11PM

40
#689 - Roman Mašek / @romario333

01/02/2011 at 06:16PM

40
#690 - Grigoriy Glushko / @grinderrz

01/05/2011 at 12:36PM