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

315 active golfers, 825 entries

Leaderboard (lowest score wins):
41
#31 - dominique pellé / @vimgolfisto

01/01/2011 at 06:02PM

41
#32 - Akira Matsuda / @a_matsuda

01/05/2011 at 03:58PM

41
#33 - Wei Dai / @clvv42

01/07/2011 at 04:06AM

41
#34 - Balkoth / @_Balkoth_

01/08/2011 at 06:02PM

41
#35 - Federico Galassi / @federicogalassi

01/28/2011 at 09:40AM

41
#36 - Justin Love / @wondible

06/14/2011 at 01:59PM

41
#37 - Hu Junfeng / @junfeng

07/17/2011 at 12:45PM

41
#38 - Albin Olsson / @sentenser

01/15/2012 at 10:40PM

41
#39 - Benoit Thiell / @benoitthiell

07/19/2012 at 10:20PM

41
#40 - Kerson Hsiao / @KersonHsiao

07/24/2012 at 07:08AM

41
#41 - Vim rocks / @vimrocks

10/06/2012 at 11:01PM

41
#42 - Hubba / @HubbaBubbaFett

12/16/2012 at 12:28PM

41
#43 - a24f0600 / @a24f0600

01/09/2013 at 10:05AM

41
#44 - Tyler / @tylerbindon

03/31/2013 at 09:44PM

41
#45 - Brent Carmer / @brent_carmer

04/09/2013 at 03:18AM

41
#46 - Trevor Powell / @DoomedBunnies

04/11/2013 at 04:55AM

41
#47 - Bradd Szonye / @bszonye

07/14/2013 at 09:50AM

41
#48 - sockdude1 / @sockdude1

11/05/2013 at 06:59AM

41
#49 - Pandu / @pandu_golf

01/05/2014 at 09:48AM

41
#50 - pikaren / @REALpikaren

01/12/2014 at 08:31AM

41
#51 - Joonas Pihlajamaa / @jokkebk

02/19/2014 at 02:59PM

41
#52 - ZorgroZ / @ZorgroZ

04/14/2014 at 09:52PM

41
#53 - kimber gonzalez / @kimberlycreates

01/21/2015 at 03:28PM

41
#54 - Dimitar Dimitrov / @kurkale6ka

03/22/2016 at 12:08PM

41
#55 - ramandeep randhawa / @rsrandhawa

04/11/2016 at 03:42AM

41
#56 - niels aamloos / @AamloosNiels

05/28/2016 at 03:08PM

41
#57 - Bill Ruddock / @biinari

10/25/2016 at 03:26PM

41
#58 - Reinaldo Astudillo / @astudillor

03/26/2017 at 11:37AM

41
#59 - Brandon Height / @Lask0x

08/09/2017 at 08:52PM

41
#60 - Darren Weston / @dazWestonUK

09/02/2017 at 01:18PM