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

1754 active golfers, 7154 entries

Leaderboard (lowest score wins):
32
#121 - Peter B / @l0wm4x

08/12/2015 at 06:42PM

32
#122 - Дима Давыдов / @xaykot

08/15/2015 at 07:56AM

32
#123 - Liam Thurston / @lthurston188

08/18/2015 at 01:06AM

32
#124 - Veritas / @_VeritasL

08/23/2015 at 03:54PM

32
#125 - Jonathan Crossley / @_jcrossley

09/06/2015 at 03:49PM

32
#126 - MikeT / @mik3t

09/14/2015 at 10:21PM

32
#127 - Mike Adams / @davis_cromwell

09/30/2015 at 02:17PM

32
#128 - ojung / @oskrjung

10/05/2015 at 02:44AM

32
#129 - Justin Sermeno / @justinsermeno

10/31/2015 at 02:45PM

32
#130 - Curt Matz / @sitrucz

11/11/2015 at 12:23AM

32
#131 - Patrick Cichon / @the_nQL

12/07/2015 at 09:54PM

32
#132 - Jon Krause / @jkrause314

12/26/2015 at 07:46PM

32
#133 - Saki Gw / @Sakigw

01/07/2016 at 10:35PM

32
#134 - Roberto Carraretto / @robcarraretto

01/08/2016 at 07:49AM

32
#135 - jackliusr / @jackliusr

01/12/2016 at 09:32AM

32
#136 - Andrii Maksai / @AMaksai

01/20/2016 at 04:24PM

32
#137 - Aleksey Zhidkov / @AlexeyZhidkov

01/21/2016 at 01:27PM

32
#138 - Daniel Suh / @18kehops

02/03/2016 at 05:41AM

32
#139 - "Smylers" / @Smylers2

02/10/2016 at 10:35AM

32
#140 - Mathias Andersson / @Wraul

02/14/2016 at 01:53PM

32
#141 - Hao Chen / @Chen_Hao

03/10/2016 at 05:48PM

32
#142 - Jonathan Taylor / @Jonyonson

03/21/2016 at 05:01AM

32
#143 - Gordon / @gordonczedik

05/20/2016 at 01:31PM

32
#144 - John Doe Sr. / @johndoe67890543

05/28/2016 at 08:25PM

32
#145 - Ameen P / @Ameen_P1

06/18/2016 at 08:08AM

32
#146 - Alonzo / @tolver_a

07/23/2016 at 10:38PM

32
#147 - jdupont655 / @jdupont655

09/02/2016 at 01:20AM

32
#148 - Stephen Aument / @saument

09/02/2016 at 03:37AM

32
#149 - hor1ace / @hor3ace

09/08/2016 at 08:20AM

32
#150 - Davis Fields / @i301585

11/04/2016 at 11:29PM