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

402 active golfers, 1057 entries

Leaderboard (lowest score wins):
44
#241 - Dom Armstrong / @dom_cycleface

09/12/2013 at 12:36PM

44
#242 - Zach Kemp / @zvksf

12/13/2013 at 08:09AM

44
#243 - Endir / @Endir2

04/18/2014 at 01:39PM

44
#244 - Jacob Joaquin / @JacobJoaquin

06/30/2014 at 04:06AM

44
#245 - Haoxuan Yue / @yuehaoxuanar

07/19/2014 at 01:22PM

44
#246 - John Clara / @johnanthclara

08/24/2015 at 08:52PM

44
#247 - Andrew Michaud / @andrewjmichaud

09/04/2015 at 07:48PM

44
#248 - Gerald Tilma / @GeraldTilma

10/22/2015 at 02:12AM

44
#249 - Ryan Marcotte / @ryanjmarcotte

11/16/2015 at 02:53PM

44
#250 - Daniel / @Daniel00288663

03/31/2017 at 10:09AM

44
#251 - Sam Hammer / @samhammer325

05/07/2017 at 03:46AM

44
#252 - Daniel de Vries / @devries_d

02/08/2018 at 04:53PM

44
#253 - Marius Jurgelenas / @MarenasLT

07/12/2018 at 12:50PM

44
#254 - Jurica / @Jurica34581259

11/19/2018 at 09:40PM

44
#255 - Delon / @delonleonard

12/22/2019 at 12:29PM

44
#256 - RockerZZY / @rocker_zzy

06/21/2020 at 12:09AM

44
#257 - Mobius / @ManiacalMobius

05/17/2021 at 12:36AM

44
#258 - Vgrbwat / @vgrbwat

06/15/2021 at 04:41AM

44
#259 - Matrices Matlab #1 / @matrices_matlab

07/13/2021 at 07:23PM

44
#260 - Sergio / @SergioVl12

07/25/2021 at 03:24AM

44
#261 - panakin skywalker / @_j3ffrey

09/02/2021 at 03:04PM

44
#262 - Matthew Beaumont / @mattybeau_dev

11/26/2021 at 04:50PM

44
#263 - shahanavaz m / @shahanavazm

02/13/2022 at 05:19AM

44
#264 - quemeraisc / @quemeraisc

05/24/2022 at 01:41PM

44
#265 - Brandon / @Brandon10678836

08/31/2022 at 11:39AM

44
#266 - Andrii Soldatenko / @a_soldatenko

10/08/2022 at 03:34PM

44
#267 - Marius Ropotica / @cipmar

04/01/2024 at 05:50PM

44
#268 - Willy / @Willy6932612311

09/08/2024 at 07:25PM

44
#269 - Brando / @brandonce

01/28/2025 at 04:48AM

44
#270 - kloir-z / @kloir-z

01/24/2026 at 01:20PM