Assignment Alignment
line up the operators. Use spaces, not tabs.
Start file
# Align these assignments x = 1 y = true z = 'you' foo = 'bar' long_name = "long variable value" $p3cial = ch4rs last = line # Much better!
End file
# Align these assignments x = 1 y = true z = 'you' foo = 'bar' long_name = "long variable value" $p3cial = ch4rs last = line # Much better!
View Diff
3,6c3,6 < x = 1 < y = true < z = 'you' < foo = 'bar' --- > x = 1 > y = true > z = 'you' > foo = 'bar' 8,9c8,9 < $p3cial = ch4rs < last = line --- > $p3cial = ch4rs > last = line
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.
#115 Jakub Arnold / @JakubArnold - Score: 31 - 12/19/11 @ 08:27
:%s/=/ &/<CR>5Gwjdwj.j.j.ZZ
0 comments
#116 Burkhard Zimmermann / @BurkZimm - Score: 31 - 12/31/11 @ 11:22
:%s/=/ &/<CR>5Gwjdwj.j.j.ZZ
0 comments
#118 Nathan Manousos / @trafnar - Score: 31 - 04/05/12 @ 23:27
:se ts=10 et<CR>:%s/ =/<C-V><Tab>=<CR>:ret<CR>ZZ
0 comments
#120 Kevin Hamer / @khamer - Score: 32 - 01/19/11 @ 14:23
2jV6j:s/ /\t<CR>:se et ts=10|ret<CR>ZZ
0 comments
#121 Alex David / @alexd_me - Score: 33 - 05/03/12 @ 20:17
jjlylqq8pj0q2@qw6puP5Pjj2PjF=5PZZ
0 comments
#122 pablo flouret / @quuxbaz - Score: 34 - 01/13/11 @ 15:23
2jw<C-V>jj8I <Esc>3jw6i <Esc>2jh2i <Esc>jbb5i <Esc>:x<CR>
0 comments
#123 szetobo / @szetobo - Score: 35 - 01/11/11 @ 22:12
:se ts=10 et<CR>:%/s<BS><BS>s/ =/<C-V><Tab>=<CR>:ret<CR>ZZ
0 comments
#124 snaky / @snaky - Score: 35 - 01/19/11 @ 04:40
jV}:s/ /\t<CR>:se et ts=10|e<BS>ret<CR>:<Esc><BS>ZZ
0 comments
#125 Dan Dorman / @dandorman - Score: 36 - 01/18/11 @ 10:24
3Gqwyt=W@=10-len(@")<CR>i <Esc>j^q3@wj2@wZZ
0 comments
#126 Miha Filej / @mfilej - Score: 36 - 11/26/11 @ 08:40
3Gqwyt=W@=10-len(@")<CR>i <Esc>j^q3@wj2@wZZ
0 comments
#127 Jyun-Fan Tsai / @fakecolor - Score: 36 - 02/10/12 @ 19:49
3G8a <Esc>j0.j0.jbbb6i <Esc>jjbi <Esc>jbb5i <Esc>ZZ
0 comments
#128 Dmitry Teslenko / @krab_mozga - Score: 38 - 01/19/11 @ 05:48
jjV}k:s/ =/ &<CR><C-V>kkel4kxgvV<.PZZ
0 comments
#129 Przemysław Pawełczyk / @przemoc86 - Score: 39 - 01/15/11 @ 11:32
jjV}k:s/ =/ &<CR><C-V>kkel4kxgvV<.PZZ
@przemoc86: It shows how I deal with such problems. Longest word can be pretty long, so counting is not an option, but you can easily spot it, right? That's why visual editors are sometimes useful or even better than scripts. In complex case awk is still a better choice, but it would be a bit longer though.
@dandorman: I really dig it. I keep forgetting about Vim's column select mode, probably because I can't think of any practical uses for it. That's really pretty slick.
2 comments
#130 Eric Andres / @eric_m_andres - Score: 41 - 12/05/12 @ 09:42
/=<CR>qqi<C-R>=repeat(' ',11-col('.'))<CR><Esc>nnq8@qZZ
0 comments
#131 Ivo Dancet / @caifara - Score: 44 - 12/03/11 @ 14:04
:set ex<Tab><CR>/=<CR><C-V>jjI<Tab> <Esc>3nni<Tab> <Esc>2jhi <Esc>nni<Tab> <Esc>ZZ
0 comments
#132 ksauzz / @ksauzz - Score: 46 - 04/24/11 @ 00:59
:set ex<Tab><CR>jjll<C-V>jj>jjjll<C-V>>xx<Esc>2jwi <Esc>jbbi<Tab> <Esc>:wq<CR>
0 comments
#133 niquola / @niquola - Score: 47 - 01/28/11 @ 15:56
:3<CR>a <Esc>+.+.+Ea <Esc>2+Ea <Esc>+Ea <Esc>:wq<CR>
0 comments
#134 Matt Donahoe / @mdonahoe - Score: 47 - 11/26/11 @ 13:41
/=<CR>i <Esc>nn.nn.nni <Esc>nnni <Esc>nni <Esc>ZZ
0 comments
#135 Philipp Bayer / @PhilippBayer - Score: 51 - 01/30/11 @ 15:58
:%s/=/ =/<CR>11|dt=k.k.k.k.k<Down><Left><Left>i <Up><Left><Left> <Up><Left><Left> <Esc>:wq<CR>
0 comments
#136 fdsfasdf / @fdsfasdf1 - Score: 52 - 12/14/11 @ 12:03
/<Esc><Esc>/=<CR>8i <Esc>nn8i <Esc>nn8i <Esc>nn8i <Esc>hxxnn2i <Esc>nn4i <Esc>i <Esc>:w<CR>:q<CR>
0 comments
#137 Tomasz Zurkowski / @doriath88 - Score: 57 - 04/18/11 @ 03:45
:%s/=/ =/g<CR><Right><Right><Right><Right><Right><Right><Right><Right><Right><Up><Right>xxx<Up>xxxxx<Left><Up>i <Left><Up><Left><Left><Esc><Right><C-V><Up><Up><Up><Down>I <Esc>ZZ
0 comments
#138 Dean / @thecamelwalk - Score: 57 - 10/17/11 @ 23:16
/=<CR>2n2n<Esc>kkkkkkjni <Esc>2n.2n.2n.i<BS><BS><Esc>3ni <Esc>2ni <Esc>:x<CR>
0 comments
#139 Takuya Nishigori / @nishigo_ri - Score: 58 - 04/24/11 @ 00:50
jjll<C-V>jjI <Esc>jjjli <Esc>jji <Esc>jbbi <Esc>:qa<CR>::w<CR>::qa<CR>
0 comments
#140 軽給 / @kei_q - Score: 61 - 04/24/11 @ 00:55
:set ex<Tab><CR>2j:se<Tab> ts=9<CR>a<Tab><Esc>j0a<Tab><Esc>j0a<Tab><Esc>j0<Tab><Esc>wa<Esc>i<Tab> <Esc>jjhi<Tab> <Esc>jF=i<Tab> <Esc>ZZ
0 comments
#141 Stephen Paul Weber / @singpolyma - Score: 65 - 01/12/11 @ 13:27
<Down><Down><Down><Right><Up><Right>i <Esc><Down><Left><Left><Left><Left><Left>.<Down><Left><Left><Left><Left><Left><Left>.<Down><Left><Left><Left><Left><Left>.x<Left>x<Down><Down><Left><Left>i <Esc><Down><Left><Left><Left><Left>i <Esc>:wq<CR>
0 comments
#142 personlink / @personlink - Score: 363 - 04/07/11 @ 01:56
Vjjjjjjjjjjjjjjjjyppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp<Esc>dddxxxxxxxxxxxxxxixxxxxx<Esc>GGVggdi# Align these assignments<CR><CR>x = 1<CR>y = true<CR>z = 'you'<CR>foo = 'bar'<CR>long_name = "long variable value"<CR>$p3cial = ch4rs<CR>last = line<CR><CR># Much better!<Esc>:wq<CR>
0 comments
VimGolf