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):
39
#1 - Turkey Man / @lvturkeyman

11/24/2017 at 08:42AM

39
#2 - azzal07 / @azzal07

03/08/2018 at 07:22PM

39
#3 - Daniël De Koker / @daniel_koker

07/11/2018 at 06:08AM

39
#4 - Miłosz Łakomy / @foobar01123

01/18/2020 at 04:59AM

39
#5 - Qing Liu / @poeminlash

08/07/2022 at 02:24AM

39
#6 - Zion Park / @zionpark93

01/09/2023 at 02:56AM

39
#7 - Peppa Pig / @PeppaPigSg

06/01/2024 at 04:01PM

39
#8 - Petro Mudrievskyj / @petemud

07/01/2024 at 10:17AM

39
#9 - Prem Netsuwan / @grnnja

08/27/2024 at 09:32AM

39
#10 - nickGPT / @nickandbro

08/29/2024 at 12:08AM

39
#11 - Sergii Pidgornyi / @spodgorn

02/14/2025 at 04:18PM

40
#12 - Andrey Ivanov / @Bytamine

08/11/2011 at 02:32PM

40
#13 - You-Siang Lin / @yslinnctu

11/30/2011 at 12:04PM

40
#14 - Pei-Lun Lee / @ypcatw

01/07/2012 at 03:29PM

40
#15 - Renat Aksitov / @Korvin79

02/07/2012 at 11:31PM

40
#16 - Zeh Rizzatti / @zehrizzatti

02/08/2012 at 05:45PM

40
#17 - Rändöm Tester / @mevcar

02/12/2012 at 04:27PM

40
#18 - Rod Knowlton / @codelahoma

05/27/2012 at 04:07AM

40
#19 - Conner McDaniel / @connermcd

09/19/2012 at 02:09AM

40
#20 - Urtica dioica / @udioica

12/13/2012 at 07:48AM

40
#21 - Adam Bell / @adamgbell

03/30/2013 at 12:26AM

40
#22 - M8R eonxi21 / @eonxi21

05/20/2013 at 06:28PM

40
#23 - Marco Hinz / @_mhinz_

05/22/2013 at 09:11AM

40
#24 - Petro Тrouq / @zulolosi

07/04/2013 at 09:23PM

40
#25 - Conor Kirkman / @conorkirkman

07/18/2013 at 06:48PM

40
#26 - Arturo Escaip / @arturoescaip

09/01/2013 at 08:55AM

40
#27 - Andrew O'Neill / @AndroidOatmeal

02/19/2014 at 06:33PM

40
#28 - John Braxler / @braxler

04/15/2014 at 07:32PM

40
#29 - David Shields / @salacio

04/22/2014 at 08:27PM

40
#30 - pftb12345 / @pftb12345

04/12/2015 at 09:08AM