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):
65
#91 - Ортемон / @the_ortemon

06/28/2023 at 11:08AM

66
#92 - Matthieu Honel / @ocus

01/28/2011 at 03:31PM

67
#93 - Helder Inacio / @inaciohj

02/03/2011 at 03:32AM

67
#94 - Torben Rasmussen / @rasmustorben

08/16/2011 at 04:34PM

69
#95 - Dmitry Teslenko / @krab_mozga

02/02/2011 at 09:43AM

69
#96 - Patrice Clement / @patrice_clement

03/18/2014 at 08:32PM

70
#97 - Jon Bettinger / @jonbettinger

01/31/2011 at 02:35AM

70
#98 - stefan otte / @stefanotte

01/30/2012 at 01:39PM

70
#99 - Arto Vuori / @dhpe

09/01/2012 at 04:50PM

71
#100 - Brando / @brandonce

02/10/2025 at 08:37AM

72
#101 - Vernon Thommeret / @synotic

01/30/2011 at 03:38PM

72
#102 - Christopher Brew / @Seph1rothVII

01/11/2012 at 12:41AM

73
#103 - Pavlo Klets / @p01nt

01/28/2011 at 03:27PM

75
#104 - Franco Lazzarino / @flazz

01/29/2011 at 12:51AM

75
#105 - grizzancs / @grizzancs

01/31/2011 at 12:13PM

77
#106 - KhaAdam / @KhaAdam

09/02/2024 at 11:48AM

79
#107 - Solomon White / @rubysolo

01/28/2011 at 04:58PM

104
#108 - Reza Lotun / @rlotun

01/30/2011 at 06:32PM

141
#109 - Ilya Grigorik / @igrigorik

02/01/2011 at 12:43AM

146
#110 - David Burns / @AutomatedTester

01/28/2011 at 03:17PM