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):
35
#391 - Benjamin Kiesl / @BenjaminKiesl

10/17/2018 at 12:01PM

35
#392 - Arno / @arnoxmp

05/17/2019 at 06:10AM

35
#393 - floyd / @floyd10086

03/16/2020 at 10:23AM

35
#394 - koyumeishi / @koyumeishi_

03/29/2020 at 03:58PM

35
#395 - Golf Gopher / @GolfGopher3

08/17/2020 at 04:56PM

35
#396 - Hermione / @HermioneNSnape

11/10/2021 at 04:54AM

35
#397 - vimgolfer220902 / @vimgolfer220902

09/02/2022 at 02:52PM

35
#398 - かみひろ / @km_hr

02/04/2023 at 05:29AM

35
#399 - Chris Atanasian / @chrisatanasian

11/16/2023 at 06:28PM

35
#400 - Eugene Mondkar / @EugeneMondkar

05/06/2024 at 01:51AM

35
#401 - Paul Molloy / @paulsmolloy

05/09/2024 at 01:47PM

35
#402 - Aly Thobani / @alythobani

05/28/2024 at 12:42AM

35
#403 - Don'tBeAlarmed / @DontBeAlarmed

05/31/2024 at 06:16PM

35
#404 - glibg10b / @glibg10b

11/18/2024 at 12:56PM

35
#405 - Nathan Priego / @nspriego

02/19/2025 at 05:19AM

36
#406 - Kerry Buckley / @kerryb

12/29/2010 at 07:55AM

36
#407 - kana / @kana1

12/29/2010 at 04:30PM

36
#408 - Akira Matsuda / @a_matsuda

12/30/2010 at 02:05AM

36
#409 - Scott Abernethy / @scott_abernethy

12/31/2010 at 03:41AM

36
#410 - Behnam Esfahbod / @zwnj

12/31/2010 at 03:01PM

36
#411 - Matthew Draper / @_matthewd

01/06/2011 at 05:53AM

36
#412 - Tim Chase / @gumnos

01/08/2011 at 03:14PM

36
#413 - Pete Johns / @johnsyweb

01/14/2011 at 09:25PM

36
#414 - Anders Janmyr / @andersjanmyr

01/16/2011 at 03:06PM

36
#415 - Jed Hurt / @meekish

02/05/2011 at 05:44AM

36
#416 - Arthur Chiu / @arthur_chiu

02/06/2011 at 02:09AM

36
#417 - Pavlo Klets / @p01nt

02/06/2011 at 07:11PM

36
#418 - Derrick Camerino / @robustdj

04/21/2011 at 02:10AM

36
#419 - Terje Larsen / @terlars

05/09/2011 at 01:16PM

36
#420 - Charles Max Wood / @cmaxw

05/24/2011 at 10:27PM