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

1792 active golfers, 7261 entries

Leaderboard (lowest score wins):
47
#1291 - Justin Thomas / @base698

04/18/2014 at 12:00AM

47
#1292 - Chris Davison / @davisonnn

05/25/2014 at 08:11PM

47
#1293 - Ch Ri / @szirocco

03/07/2015 at 09:54AM

47
#1294 - Antti A / @anttia

07/22/2015 at 03:37PM

47
#1295 - Sergey Semushin / @Predelnik

08/26/2015 at 06:04AM

47
#1296 - Joey / @joeyism101

09/03/2015 at 03:03PM

47
#1297 - Austin Wood / @indiesquidge

01/25/2016 at 05:54PM

47
#1298 - Pratap Koritala / @pratap_koritala

02/19/2016 at 07:53AM

47
#1299 - malet / @Malet

06/22/2016 at 07:40PM

47
#1300 - Nota Fool / @f970823

07/26/2016 at 06:04PM

47
#1301 - Thiago Belem / @TiuTalk

08/31/2016 at 03:58AM

47
#1302 - timerella® / @timerella

11/17/2016 at 12:13AM

47
#1303 - Миша Сорокин / @rafmikovi4

04/10/2017 at 11:33AM

47
#1304 - Jonas Sunde V / @sunde_v

08/04/2017 at 03:58PM

47
#1305 - Tim / @timothyscosta

03/09/2018 at 09:05AM

47
#1306 - niwatoco / @yoshitune9

07/19/2018 at 06:48PM

47
#1307 - Gitsnik / @dracyrys

04/22/2019 at 12:33PM

47
#1308 - Ifeoluwa Lawal / @IfeLawl

10/19/2020 at 03:45PM

47
#1309 - MathijsHoogland / @MathijsHoogland

11/04/2020 at 09:51AM

47
#1310 - Antonio D. González / @antoniodgonz

03/16/2022 at 10:51PM

47
#1311 - Chao Sang / @menglong2234

07/05/2022 at 08:53AM

47
#1312 - NI57721 / @NI57721

11/30/2022 at 07:48PM

47
#1313 - coffee-addict / @o0ff3e6ddict

05/19/2023 at 05:50PM

47
#1314 - Chris Shaffer / @clstopher

12/22/2023 at 03:36AM

47
#1315 - satake0916 / @satake0916

01/03/2024 at 01:22AM

47
#1316 - wihinenh / @wihinenh

04/07/2024 at 10:00AM

47
#1317 - mwln / @mwln

04/07/2024 at 11:38PM

47
#1318 - OsamaElkadeem / @OsamaElkadeem

08/08/2024 at 02:43PM

47
#1319 - bcfoster / @bcfoster

09/04/2024 at 05:20AM

47
#1320 - NotShanks / @NotShanks

05/19/2025 at 04:25AM