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 310 remaining solutions by signing in and submitting your own entry
#311 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

311 active golfers, 812 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

40
#4 - Andrey Ivanov / @Bytamine

08/11/2011 at 02:32PM

40
#5 - You-Siang Lin / @yslinnctu

11/30/2011 at 12:04PM

40
#6 - Pei-Lun Lee / @ypcatw

01/07/2012 at 03:29PM

40
#7 - Renat Aksitov / @Korvin79

02/07/2012 at 11:31PM

40
#8 - Zeh Rizzatti / @zehrizzatti

02/08/2012 at 05:45PM

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

02/12/2012 at 04:27PM

40
#10 - Rod Knowlton / @codelahoma

05/27/2012 at 04:07AM

40
#11 - Conner McDaniel / @connermcd

09/19/2012 at 02:09AM

40
#12 - Urtica dioica / @udioica

12/13/2012 at 07:48AM

40
#13 - Adam Bell / @adamgbell

03/30/2013 at 12:26AM

40
#14 - M8R eonxi21 / @eonxi21

05/20/2013 at 06:28PM

40
#15 - Marco Hinz / @_mhinz_

05/22/2013 at 09:11AM

40
#16 - Petro Тrouq / @zulolosi

07/04/2013 at 09:23PM

40
#17 - Conor Kirkman / @conorkirkman

07/18/2013 at 06:48PM

40
#18 - Arturo Escaip / @arturoescaip

09/01/2013 at 08:55AM

40
#19 - Andrew O'Neill / @AndroidOatmeal

02/19/2014 at 06:33PM

40
#20 - John Braxler / @braxler

04/15/2014 at 07:32PM

40
#21 - David Shields / @salacio

04/22/2014 at 08:27PM

40
#22 - pftb12345 / @pftb12345

04/12/2015 at 09:08AM

40
#23 - JinHwan Choi / @jinhwanlazy

03/26/2016 at 06:50AM

40
#24 - Chenut Ludovic / @7Brwa7

04/04/2016 at 12:11PM

40
#25 - Jon Krause / @jkrause314

04/11/2016 at 08:46PM

40
#26 - Ameen P / @Ameen_P1

06/18/2016 at 10:06AM

40
#27 - sijinyuan / @sijinyuan

03/18/2017 at 06:00AM

40
#28 - DHM / @DHM29978992

04/30/2018 at 03:33AM

40
#29 - Brendan B Amdocs / @AmdocsB

09/27/2018 at 03:33PM

41
#30 - dominique pellé / @vimgolfisto

01/01/2011 at 06:02PM