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
#151 - Zhihong Liu / @pieapple03

02/07/2017 at 03:08PM

32
#152 - Vimgolf / @vimgolf987

02/27/2017 at 06:17AM

32
#153 - Andreas Anderbach / @anderbacha

03/20/2017 at 04:02PM

32
#154 - 20speedvegan / @ashkevinm

04/12/2017 at 05:10PM

32
#155 - sijinyuan / @sijinyuan

04/13/2017 at 03:36PM

32
#156 - 梧桐王子 / @WutongYujie

04/25/2017 at 03:53AM

32
#157 - Fausto NA / @brainlessdev

05/15/2017 at 12:18PM

32
#158 - Acid One / @AcidOne2

05/31/2017 at 10:48AM

32
#159 - Turkey Man / @lvturkeyman

11/08/2017 at 03:31PM

32
#160 - ParasamGateZero / @ParasamGateZero

01/22/2018 at 12:23AM

32
#161 - Andrew Peterson / @FungalRaincloud

07/30/2018 at 12:28AM

32
#162 - Coruja Queridinha / @miriamretka

08/24/2018 at 05:37PM

32
#163 - royer / @RoyerMoyer1

09/22/2018 at 02:07PM

32
#164 - Alejandro Santander / @_ajsantander

10/14/2018 at 06:59PM

32
#165 - Malcolm Sharpe / @blueblimpms

08/13/2019 at 09:03PM

32
#166 - Arthur Goodman / @ArthurGoodman3

05/02/2020 at 01:40PM

32
#167 - chocolate / @chocola81394123

11/28/2020 at 05:54PM

32
#168 - Jung Yeon Park / @park_jungy

01/05/2021 at 11:55PM

32
#169 - lydxn / @lydxn1

07/24/2021 at 09:52PM

32
#170 - Sean Hwang / @SeanHwangt

02/02/2022 at 01:00AM

32
#171 - Pedro Minicz / @pedrominicz

03/26/2022 at 10:22PM

32
#172 - Andreas Näsman / @andreas_nasman

06/17/2022 at 10:41AM

32
#173 - Александр Моисеев / @Aleksan43607471

01/19/2023 at 10:37AM

32
#174 - QKSDM / @qksdm

02/01/2024 at 06:54PM

32
#175 - Simo Kivistö / @kivissimo

02/05/2024 at 08:04PM

32
#176 - Petro Mudrievskyj / @petemud

06/27/2024 at 09:09AM

32
#177 - Peppa Pig / @PeppaPigSg

09/13/2024 at 02:42AM

32
#178 - Alexander Ivanov / @karamfil

11/27/2024 at 08:55PM

33
#179 - iCross / @iCrossOfficial

02/01/2011 at 04:52PM

33
#180 - Joost / @vlabakje

02/20/2011 at 01:17PM