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

1369 active golfers, 5569 entries

Leaderboard (lowest score wins):
54
#1231 - Andrew Loucky / @merely_oolong

03/24/2014 at 11:21PM

54
#1232 - Samir Sadek / @netsamir

07/21/2015 at 05:52AM

54
#1233 - Conor Ryan / @conorjryan

11/18/2015 at 09:16AM

54
#1234 - Matt Walsh / @wattmalsh

02/06/2017 at 10:42PM

54
#1235 - Netznarkose / @netznarkose

07/27/2017 at 09:21PM

54
#1236 - Justin Hoyt / @JustinHoyt24

06/23/2018 at 05:17PM

55
#1237 - Jonathan Wallace / @jonathanwallace

12/29/2010 at 03:02AM

55
#1238 - Harold Giménez / @hgimenez

01/03/2011 at 11:11PM

55
#1239 - mlkjih / @mlkjih

02/15/2011 at 11:59AM

55
#1240 - jcastaneyra / @jcastaneyra

06/08/2011 at 06:21AM

55
#1241 - Christoffer Lejdborg / @Lejdborg

09/09/2011 at 02:35PM

55
#1242 - IPhone Notiz / @MyIPhoneNotes

11/10/2011 at 10:41PM

55
#1243 - Alex Marchant / @alex_marchant

07/16/2012 at 10:09AM

55
#1244 - Kerry Burke / @kurver

09/11/2012 at 10:43AM

55
#1245 - Joseph McDonald / @jots

05/07/2013 at 12:15AM

55
#1246 - Geordee Naliyath / @geordee

03/14/2014 at 06:36PM

55
#1247 - d c / @chikenwaffle

07/11/2014 at 10:41PM

56
#1248 - Phil / @phil30075

12/28/2010 at 10:01PM

56
#1249 -  Ikhsan Maulana / @ixandidu

12/29/2010 at 09:27AM

56
#1250 - Adriano Bacha / @adrianobacha

02/05/2012 at 09:18PM

56
#1251 - Matthew LeBourgeois / @mwlebour

10/18/2012 at 05:56PM

56
#1252 - Rajesh Rajan / @rvenkataguru

01/09/2013 at 02:41AM

56
#1253 - Joe Jackson / @anything_joes

05/12/2013 at 03:12PM

56
#1254 - Bobby Burden / @bobbyrburden

12/20/2013 at 07:38PM

56
#1255 - Alex Quach / @imalexquach

09/20/2016 at 10:29PM

56
#1256 - sspan / @sspantz

07/09/2018 at 03:35AM

56
#1257 - 강현 / @Applesquiz

01/27/2019 at 04:21PM

56
#1258 - scottarver / @scottarver

03/02/2019 at 05:28AM

56
#1259 - Phoon / @justflashhim

05/13/2019 at 01:20AM

57
#1260 - Marty McGuire / @schmarty

12/28/2010 at 07:32PM