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 4d42cde1e6dc010cb7000024

expand a list comprehension (python)

Please show your way to convert a list comprehension in python to an ordinary for-loop expression!

Start file
print [x**2 for x in xrange(10)]
End file
tmp = []
for x in xrange(10):
    tmp.append(x**2)
print tmp

View Diff

1c1,4
< print [x**2 for x in xrange(10)]
---
> tmp = []
> for x in xrange(10):
>     tmp.append(x**2)
> print tmp

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 109 remaining solutions by signing in and submitting your own entry
#110 David Burns / @AutomatedTester - Score: 146 - 01/28/11 @ 15:17
itmp = []<CR><Esc><Right><Right><Right><Right><Right><Right><Right><Right><Right><Right><Right><Right>v<Right><Right><Right><Right><Right><Right><Right><Right><Right><Right><Right><Right><Right><Right><Right><Right><Right><Right>x<Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left>pu<Left>o<Up><CR><Up><Esc>pi<Right>:<Down><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><CR><Up><Tab><BS>    tmp.append(<Esc><Down><Right>v<Right><Right><Right>x<Up>pi<Right>)<Down><BS><BS><BS>tmp<Esc><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left>dw<Down>dd:wq<CR>

0 comments


Created by: @vimgolfer

110 active golfers, 334 entries

Leaderboard (lowest score wins):
42
#1 - xhtmlforum / @xhtmlforum

01/28/2011 at 10:51PM

42
#2 - Pete Johns / @johnsyweb

01/29/2011 at 12:48AM

42
#3 - Tim Chase / @gumnos

01/29/2011 at 12:56AM

42
#4 - Steve Morrow / @yawmark

01/29/2011 at 02:48PM

42
#5 - Wei Dai / @clvv42

01/30/2011 at 03:58AM

42
#6 - Oleg Roshupkin / @jjjahson

02/01/2011 at 11:39AM

42
#7 - Ujjwol Lamichhane / @Ujjwol

02/03/2011 at 02:58AM

42
#8 - Balkoth / @_Balkoth_

02/03/2011 at 09:45PM

42
#9 - Junfeng / @junfeng

08/01/2011 at 02:42PM

42
#10 - You-Siang Lin / @yslinnctu

11/30/2011 at 05:39AM

42
#11 - Urtica dioica / @udioica

12/16/2012 at 04:24AM

42
#12 - Marco Hinz / @_mhinz_

05/28/2013 at 08:19AM

42
#13 - John Braxler / @braxler

06/09/2014 at 10:16PM

42
#14 - Turkey Man / @lvturkeyman

12/18/2017 at 07:57AM

42
#15 - Ming Dai / @MingDai2

07/07/2020 at 09:13PM

42
#16 - Qing Liu / @poeminlash

08/07/2022 at 05:27AM

42
#17 - Jean George / @JeanGeo20504212

10/14/2023 at 11:39PM

42
#18 - Peppa Pig / @PeppaPigSg

06/02/2024 at 07:19AM

42
#19 - nickGPT / @nickandbro

08/28/2024 at 11:02PM

43
#20 - Federico Galassi / @federicogalassi

01/28/2011 at 09:52PM

43
#21 - flo / @c4p0ne

01/31/2011 at 01:06PM

43
#22 - Justin Love / @wondible

09/07/2011 at 12:54PM

43
#23 - Rändöm Tester / @mevcar

02/12/2012 at 03:59PM

43
#24 - William Dunand / @wdunand

03/06/2012 at 08:34AM

43
#25 - Chester Yap / @Chest_ErYap

08/10/2019 at 08:52PM

43
#26 - roudens / @roudens2

02/07/2021 at 11:18AM

44
#27 - Michał Taszycki / @mehowte

01/29/2011 at 06:51PM

44
#28 - Joonas Pihlajamaa / @jokkebk

02/25/2014 at 03:25PM

45
#29 - Jon Krause / @jkrause314

04/18/2016 at 10:39PM

46
#30 - h_east (トロッコ6個) / @h_east

01/29/2011 at 07:26AM