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):
49
#1141 - Kirill Sidenko / @KirillSidenko

06/19/2016 at 12:13PM

49
#1142 - Charlie OConor / @charlieoconor

10/30/2017 at 04:53PM

49
#1143 - faisal / @faisalhackshah

11/25/2018 at 03:28AM

50
#1144 - Jordan Lewis / @JordanALewis

12/30/2010 at 06:47PM

50
#1145 - Oleg Pestov / @opestov

03/14/2011 at 06:19PM

50
#1146 - Unreal Name / @morphles

06/02/2011 at 11:06AM

50
#1147 - approaching236 / @approaching236

06/22/2011 at 11:49PM

50
#1148 - Josh / @beau_jo

08/01/2011 at 07:55PM

50
#1149 - den野郎 / @asihuretti

01/07/2012 at 05:00AM

50
#1150 - Thomas Pfeiffer / @pfeiffdrauf

02/29/2012 at 04:05PM

50
#1151 - levicook / @levicook

03/28/2012 at 07:27PM

50
#1152 - Ryan Knowles / @RyKnowl

11/17/2012 at 01:28AM

50
#1153 - HongKilDong / @HongKilDong

03/12/2013 at 12:44PM

50
#1154 - Vincent Lee / @vincentleest

07/04/2013 at 07:00AM

50
#1155 - David Pathakjee / @DavidPathakjee

08/14/2013 at 03:47AM

50
#1156 - Peder Sørensen / @pedersorensen86

08/23/2013 at 10:18AM

50
#1157 - yoohey / @yoohey_m

10/22/2013 at 12:16PM

50
#1158 - Raphael / @rnstlr

11/24/2013 at 04:17PM

50
#1159 - Aurélien Vallée / @aurelienvallee

02/04/2014 at 11:58AM

50
#1160 - Jeff / @sir_wiggles3

09/09/2018 at 02:51AM

50
#1161 - Maas Lalani / @maaslalani

12/07/2018 at 03:18AM

50
#1162 - fucus / @fishlovebanana

03/21/2019 at 07:02AM

51
#1163 - Pierre / @Pihour

12/30/2010 at 07:44PM

51
#1164 - neleai / @enlaei

12/31/2010 at 10:50PM

51
#1165 - Ben Hall / @Ben_Hall

01/03/2011 at 01:45PM

51
#1166 - Jamie Mill / @jamiemill

12/14/2011 at 09:08PM

51
#1167 - Ben Wagaman / @jamin4jc

01/13/2012 at 04:23PM

51
#1168 - Julian / @ShumpEvenwood

11/25/2012 at 04:43PM

51
#1169 - Adam Bell / @adamgbell

02/13/2013 at 06:00PM

51
#1170 - Stephen Tindall / @stindall77

02/21/2013 at 06:02PM