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

1358 active golfers, 5529 entries

Leaderboard (lowest score wins):
32
#121 - Дима Давыдов / @xaykot

08/15/2015 at 07:56AM

32
#122 - Liam Thurston / @lthurston188

08/18/2015 at 01:06AM

32
#123 - Veritas / @_VeritasL

08/23/2015 at 03:54PM

32
#124 - Jonathan Crossley / @_jcrossley

09/06/2015 at 03:49PM

32
#125 - MikeT / @mik3t

09/14/2015 at 10:21PM

32
#126 - Mike Adams / @davis_cromwell

09/30/2015 at 02:17PM

32
#127 - ojung / @oskrjung

10/05/2015 at 02:44AM

32
#128 - Justin Sermeno / @justinsermeno

10/31/2015 at 02:45PM

32
#129 - Curt Matz / @sitrucz

11/11/2015 at 12:23AM

32
#130 - Patrick Cichon / @the_nQL

12/07/2015 at 09:54PM

32
#131 - Jon Krause / @jkrause314

12/26/2015 at 07:46PM

32
#132 - Saki Gw / @Sakigw

01/07/2016 at 10:35PM

32
#133 - Roberto Carraretto / @robcarraretto

01/08/2016 at 07:49AM

32
#134 - jackliusr / @jackliusr

01/12/2016 at 09:32AM

32
#135 - Andrii Maksai / @AMaksai

01/20/2016 at 04:24PM

32
#136 - Aleksey Zhidkov / @AlexeyZhidkov

01/21/2016 at 01:27PM

32
#137 - Daniel Suh / @18kehops

02/03/2016 at 05:41AM

32
#138 - Smylers / @Smylers2

02/10/2016 at 10:35AM

32
#139 - Mathias Andersson / @Wraul

02/14/2016 at 01:53PM

32
#140 - Hao Chen / @Chen_Hao

03/10/2016 at 05:48PM

32
#141 - Jonathan Taylor / @Jonyonson

03/21/2016 at 05:01AM

32
#142 - Gordon / @gordonczedik

05/20/2016 at 01:31PM

32
#143 - John Doe Sr. / @johndoe67890543

05/28/2016 at 08:25PM

32
#144 - Ameen P / @Ameen_P1

06/18/2016 at 08:08AM

32
#145 - Alonzo / @tolver_a

07/23/2016 at 10:38PM

32
#146 - jdupont655 / @jdupont655

09/02/2016 at 01:20AM

32
#147 - Stephen Aument / @saument

09/02/2016 at 03:37AM

32
#148 - hor1ace / @hor3ace

09/08/2016 at 08:20AM

32
#149 - Davis Fields / @i301585

11/04/2016 at 11:29PM

32
#150 - Zhihong Liu / @pieapple03

02/07/2017 at 03:08PM