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):
53
#361 - Jan Kassens / @kassens

12/29/2010 at 03:30PM

53
#362 - Thibault Jouan / @tjouan

12/29/2010 at 10:17PM

53
#363 - Jean-Charles Quillet / @jc_jecaro

05/19/2020 at 03:30PM

54
#364 - Kishyr Ramdial / @kishyr

12/29/2010 at 03:44PM

54
#365 - Juan C. Muller / @juancmuller

12/31/2010 at 04:15AM

54
#366 - Justin Knag / @justinknag

08/28/2014 at 11:28AM

55
#367 - Alexey Komissarouk / @alexeymk

12/29/2010 at 01:19PM

55
#368 - smokey42 / @smokey42

12/29/2010 at 02:34PM

55
#369 - Ed Gibbs / @edward_gibbs

08/17/2011 at 02:22PM

55
#370 - Ska / @skaa42

07/16/2021 at 06:51PM

57
#371 - Tom Husson / @thusson13

12/29/2010 at 04:23PM

58
#372 - Billy / @Billy67965753

06/07/2019 at 10:22PM

59
#373 - Pablo Ambrosio / @pandres_

12/29/2010 at 05:49PM

61
#374 - Nick Jones / @nickj89

12/29/2010 at 12:27PM

62
#375 - David Bengoa / @DvdBng

12/29/2010 at 01:14PM

66
#376 - Markus Nilsson / @markusnilsson

12/29/2010 at 04:02PM

66
#377 - digitalparoxysm / @digitalparoxysm

12/29/2010 at 06:48PM

66
#378 - Matty Williams / @matty_jwilliams

04/26/2012 at 08:03PM

72
#379 - Luis Fernando Rodríguez Vargas / @LuisFerRodVar

06/25/2024 at 07:43PM

83
#380 - Timothy Hahn / @timyhahn

04/20/2012 at 03:30AM

83
#381 - Trever Marshall / @dynamic_library

10/12/2012 at 08:49PM

93
#382 - Zhao Yao / @Lynch8080

12/31/2010 at 05:33PM