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 4d1b1b97c58eaa2a8a0002fc

Python Hello World! Reformatting

A novice Python using prints Hello World! and a pro shows him different way. Using vim to get into pro style from novice, win the challenge.

Start file
#!/usr/bin/python
import sys
a
= "Hello World!"
sys
.stdout.write(str(a[0]))
sys
.stdout.write(str(a[1]))
sys
.stdout.write(str(a[2]))
sys
.stdout.write(str(a[3]))
sys
.stdout.write(str(a[4]))
sys
.stdout.write(str(a[5]))
sys
.stdout.write(str(a[6]))
sys
.stdout.write(str(a[7]))
sys
.stdout.write(str(a[8]))
sys
.stdout.write(str(a[9]))
sys
.stdout.write(str(a[10]))
sys
.stdout.write(str(a[11]))
End file
#!/usr/bin/python
import sys
a
= "Hello World!"
for i in range(0, len(a)):
  sys
.stdout.write(str(a[i]))

View Diff

4,15c4,5
< sys.stdout.write(str(a[0]))
< sys.stdout.write(str(a[1]))
< sys.stdout.write(str(a[2]))
< sys.stdout.write(str(a[3]))
< sys.stdout.write(str(a[4]))
< sys.stdout.write(str(a[5]))
< sys.stdout.write(str(a[6]))
< sys.stdout.write(str(a[7]))
< sys.stdout.write(str(a[8]))
< sys.stdout.write(str(a[9]))
< sys.stdout.write(str(a[10]))
< sys.stdout.write(str(a[11]))
---
> for i in range(0, len(a)):
>   sys.stdout.write(str(a[i]))

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 381 remaining solutions by signing in and submitting your own entry
#382 Zhao Yao / @Lynch8080 - Score: 93 - 12/31/10 @ 17:33
jjj12ddofor i in range()<Esc>i0, len()<Esc>ia<Esc>$a:<CR><BS>  sysy<BS>.stu<BS>dout.write()<Esc>istr()<Esc>ia[]<Esc>ii<Esc>:wq<CR>

0 comments


Created by: @Ujjwol

382 active golfers, 1000 entries

Leaderboard (lowest score wins):
45
#271 - Pierre / @Pihour

12/30/2010 at 06:27AM

45
#272 - David Shaw / @shawthings

12/30/2010 at 09:53AM

45
#273 - Behnam Esfahbod / @zwnj

12/30/2010 at 12:38PM

45
#274 - Joshua Flanagan / @jflanagan

01/01/2011 at 04:02PM

45
#275 - Asmund / @herrasbe

01/02/2011 at 06:30AM

45
#276 - Prody / @Prody225

01/02/2011 at 07:19PM

45
#277 - Pawka / @Pawka

01/16/2011 at 11:44AM

45
#278 - Julien Pivotto / @roidelapluie

03/17/2011 at 09:24PM

45
#279 - Ilya Strukov / @i1ey

05/02/2011 at 06:13AM

45
#280 - Dario Cazzaro / @darioqa

09/18/2011 at 10:39PM

45
#281 - Dj Vimgolf / @dj_vimgolf

01/01/2012 at 04:04PM

45
#282 - Golf Sinteppadon / @minigolf2000

04/27/2012 at 12:06AM

45
#283 - Daniel Lundin / @danielundin

05/04/2012 at 02:22PM

45
#284 - cj / @cj01101

08/17/2013 at 07:35PM

45
#285 - Daniel Gray / @DanielFGray

10/15/2013 at 10:56AM

45
#286 - foo / @foo88832727

10/18/2013 at 06:06PM

45
#287 - Bjorn / @bjorn_248

11/15/2013 at 08:04PM

45
#288 - Marcus Kellerman / @sharkusk

03/30/2014 at 07:43AM

45
#289 - d c / @chikenwaffle

07/12/2014 at 04:40AM

45
#290 - かしゅーなっつ@修行中 / @kashew_nuts

08/02/2014 at 06:56AM

45
#291 - Miles Cranmer / @MilesCranmer

12/17/2019 at 06:59PM

45
#292 - Alaris Morissette / @Alaris_Villain

07/26/2021 at 07:02AM

45
#293 - xiaoao1024 / @xiaoao1024

12/28/2023 at 10:42AM

45
#294 - Bùi Lê Huỳnh / @wyattbui

06/11/2024 at 02:58PM

46
#295 - Gautier / @Gowtier

12/29/2010 at 12:31PM

46
#296 - Ray / @zer01ne

12/30/2010 at 10:34PM

46
#297 - Yannick LM / @yanicklm

12/30/2010 at 11:11PM

46
#298 - Guillaume Bonnoron / @gbonnoron

12/31/2010 at 11:38AM

46
#299 - Carl Friedrich Bolz / @cfbolz

01/04/2011 at 11:10PM

46
#300 - Thom Hughes / @thom_hughes_1

03/28/2011 at 08:54AM