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):
42
#91 - Josh Weinberg / @jcweinberg

01/01/2011 at 06:17PM

42
#92 - Ricardo Mendes / @locks

01/01/2011 at 06:32PM

42
#93 - derp derp / @derp__

01/01/2011 at 11:38PM

42
#94 - Peter Anselmo / @peter_anselmo

01/02/2011 at 07:28PM

42
#95 - rabidpraxis / @rabidpraxis

01/02/2011 at 11:25PM

42
#96 - Gael / @darkael2

01/06/2011 at 11:53PM

42
#97 - Tim Chase / @gumnos

01/09/2011 at 03:05AM

42
#98 - Pete Johns / @johnsyweb

01/12/2011 at 08:58PM

42
#99 - h_east (トロッコ6個) / @h_east

01/16/2011 at 07:42AM

42
#100 - Justin Liu / @j10

01/17/2011 at 07:24AM

42
#101 - Oleg Roshupkin / @jjjahson

01/21/2011 at 07:38PM

42
#102 - Joost / @vlabakje

02/14/2011 at 09:00AM

42
#103 - vg / @vimgolfer

02/26/2011 at 04:51PM

42
#104 - mightyfoo / @mightyfoo

05/26/2011 at 10:33AM

42
#105 - Jim Infield / @jinfield

07/20/2011 at 06:56PM

42
#106 - Neil / @spameldoon

08/21/2011 at 12:03AM

42
#107 - Daniel Hjerth / @danielhjerth

11/09/2011 at 05:12PM

42
#108 - William Dunand / @wdunand

12/02/2011 at 08:17AM

42
#109 - Ashley Feniello / @AshleyFen

01/29/2012 at 05:46AM

42
#110 - snuffling / @snuffling

02/13/2012 at 05:30AM

42
#111 - じょんあば / @john_ababa

02/23/2012 at 08:29AM

42
#112 - Chris Brown / @engineercyb

07/31/2012 at 08:21PM

42
#113 - Dan Oneata / @DanOneata

08/04/2012 at 10:14AM

42
#114 - 4L41N / @4L41N1

11/09/2012 at 09:51AM

42
#115 - Kenneth Waters / @gen_witt

11/13/2012 at 09:42PM

42
#116 - André / @Joschasa

12/24/2012 at 09:51PM

42
#117 - Rasmus Prentow / @rasmusprentow

05/13/2013 at 11:55AM

42
#118 - Dr Rev J. “I am not a bot!” Kirchartz, KSC, KHS / @JKirchartz

07/21/2013 at 01:46PM

42
#119 - Fernando Axel Ellis / @Axel_Ellis

09/13/2013 at 09:12PM

42
#120 - Stephen Drodge / @sjdrodge

10/08/2013 at 03:04AM