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

100 active golfers, 267 entries

Leaderboard (lowest score wins):
48
#31 - Ivan Nečas / @iNecas

01/31/2011 at 10:56PM

48
#32 - Christopher Erin / @MCNormalMode

09/27/2011 at 12:36AM

49
#33 - Xavier Nayrac / @lkdjiin

01/08/2012 at 11:35AM

49
#34 - cj / @cj01101

02/05/2014 at 10:55PM

50
#35 - Eivind Jahren / @HaskellElephant

02/02/2011 at 10:14PM

50
#36 - Ibrahim Tencer / @ibrahimtencer

02/13/2012 at 04:40AM

50
#37 - Yann Moisan / @YannMoisan

01/13/2013 at 07:57PM

51
#38 - Dan Masquelier / @danmasq

07/01/2011 at 09:32PM

51
#39 - Jesús Espino / @jespinog

09/06/2011 at 10:29PM

51
#40 - 無ん垢の叫び / @john_ababa

02/27/2012 at 08:04AM

51
#41 - Daniel Lundin / @danielundin

05/11/2012 at 12:20PM

51
#42 - John Piasetzki / @jpiasetz

07/13/2012 at 07:03AM

52
#43 - iCross / @iCrossOfficial

01/30/2011 at 07:46PM

52
#44 - Thom Hughes / @thom_hughes_1

03/27/2011 at 01:42PM

52
#45 - Nolen Royalty / @NolenRoyalty

04/20/2012 at 06:25PM

52
#46 - r. / @rmarvie

12/23/2014 at 09:05PM

52
#47 - RockerZZY / @rocker_zzy

08/11/2020 at 12:17PM

53
#48 - Tact Overflow / @muppling

02/07/2011 at 08:22PM

53
#49 - Arthur Hinh / @arthur_hinh

03/26/2011 at 04:20AM

53
#50 - Avinash Baliga / @avinashbaliga

03/27/2011 at 08:41PM

54
#51 - Artem Dudarev / @dudarev

01/30/2011 at 04:25PM

54
#52 - Joost / @vlabakje

02/12/2011 at 12:29AM

54
#53 - Nicola Paolucci / @durdn

02/25/2011 at 09:04PM

54
#54 - Mauro Persano / @fzort

11/22/2014 at 03:50PM

55
#55 - Jay Phillips / @jicksta

01/30/2011 at 09:15PM

55
#56 - Chris Penkett / @chrispenkett

04/03/2012 at 06:57PM

55
#57 - James / @Dronak

09/20/2014 at 05:54PM

55
#58 - Marcus Loo / @MarcusLoo1

09/19/2019 at 06:28PM

56
#59 - Matti Hänninen / @mjhanninen

01/30/2011 at 09:35PM

56
#60 - Ian McCowan / @valrus

05/29/2011 at 08:34PM