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):
48
#331 - Roland Crosby / @roooooland

12/30/2010 at 08:40AM

48
#332 - Mikel Ward / @mikelward

12/30/2010 at 10:01AM

48
#333 - jonbell17 / @jonbell17

12/30/2010 at 08:03PM

48
#334 - drio / @drio

01/02/2011 at 02:00PM

48
#335 - Alexei Eleusis Díaz / @alexeieleusis

01/01/2023 at 04:07PM

49
#336 - Jan B. / @bracki

12/29/2010 at 12:06PM

49
#337 - Lasse Højgaard / @lhojgaard

12/29/2010 at 12:32PM

49
#338 - Drew Neil / @nelstrom

12/29/2010 at 01:28PM

49
#339 - Chris Flynn / @flynnguy

12/29/2010 at 04:14PM

49
#340 - Andrei Chirila / @andrei_chirila

12/30/2010 at 04:18PM

49
#341 - Ryan Kanno / @ryankanno

01/07/2011 at 07:54AM

49
#342 - Stephen Gordon / @DubsGordon

08/01/2011 at 11:28PM

49
#343 - Aaron Josephs / @aaronjosephs1

05/02/2013 at 02:18AM

49
#344 - Sebastian / @dersharky

05/12/2020 at 08:21PM

49
#345 - Olivier Bégassat / @zk_evm

05/27/2023 at 05:19PM

49
#346 - Luke M / @lukemv

06/15/2024 at 01:51AM

50
#347 - Aleksander Balicki / @alekbalicki

12/29/2010 at 02:11PM

50
#348 - Dezső Zoltán / @zakiazigazi

12/29/2010 at 04:04PM

50
#349 - Jack Kordas / @JackKordas

12/29/2010 at 04:08PM

50
#350 - Alain Gilbert / @alain_gilbert

12/30/2010 at 06:09AM

50
#351 - Diwakar Singh Parmar / @parmardiwakar150

08/27/2024 at 12:56PM

51
#352 - Linus G Thiel / @yesbabyyes

12/29/2010 at 01:55PM

51
#353 - Boris Barroso / @borisb

12/29/2010 at 07:27PM

51
#354 - cracoucax / @cracoucax

12/30/2010 at 11:00AM

51
#355 - Su. / @0moMi

12/31/2010 at 12:16AM

51
#356 - RobertT / @techrt2050

09/22/2013 at 05:18AM

51
#357 - Benjamin Kiefer / @bkiefs

04/18/2019 at 08:53PM

52
#358 - Nacho Barrientos / @nachobarrientos

12/29/2010 at 12:25PM

52
#359 - Knaughty / @Kn4ughty

08/27/2024 at 02:51AM

53
#360 - Chris Faulkner / @bookdarts

12/29/2010 at 12:34PM