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 53369b712a09c1000223fb57

Two become one

We have two c arrays and want to make one two dimensional out of it. Can we do that?

Start file
/* Frame (32 bytes) */
static const unsigned char pkt1[32] = {
0x08, 0x60, 0x6e, 0xf1, 0x3c, 0xb9, 0x9c, 0xc7, /* .`n.<... */
0xa6, 0x35, 0x08, 0x12, 0x08, 0x00, 0x45, 0x00, /* .5....E. */
0x05, 0xdc, 0x1b, 0xe3, 0x40, 0x00, 0x31, 0x06, /* ....@.1. */
0xe8, 0xc8, 0xcb, 0xd9, 0x00, 0xda, 0xc0, 0xa8  /* ........ */
};

/* Frame (32 bytes) */
static const unsigned char pkt2[32] = {
0x08, 0x60, 0x6e, 0xf1, 0x3c, 0xb9, 0x9c, 0xc7, /* .`n.<... */
0xa6, 0x35, 0x08, 0x12, 0x08, 0x00, 0x45, 0x00, /* .5....E. */
0x05, 0xdc, 0x6b, 0x98, 0x40, 0x00, 0x31, 0x06, /* ..k.@.1. */
0x99, 0x13, 0xcb, 0xd9, 0x00, 0xda, 0xc0, 0xa8, /* ........ */
};
End file
/* Frame (32 bytes) */
static const unsigned char pkt1[2][32] = {
	{
	0x08, 0x60, 0x6e, 0xf1, 0x3c, 0xb9, 0x9c, 0xc7, /* .`n.<... */
	0xa6, 0x35, 0x08, 0x12, 0x08, 0x00, 0x45, 0x00, /* .5....E. */
	0x05, 0xdc, 0x1b, 0xe3, 0x40, 0x00, 0x31, 0x06, /* ....@.1. */
	0xe8, 0xc8, 0xcb, 0xd9, 0x00, 0xda, 0xc0, 0xa8  /* ........ */
	},
	{
	0x08, 0x60, 0x6e, 0xf1, 0x3c, 0xb9, 0x9c, 0xc7, /* .`n.<... */
	0xa6, 0x35, 0x08, 0x12, 0x08, 0x00, 0x45, 0x00, /* .5....E. */
	0x05, 0xdc, 0x6b, 0x98, 0x40, 0x00, 0x31, 0x06, /* ..k.@.1. */
	0x99, 0x13, 0xcb, 0xd9, 0x00, 0xda, 0xc0, 0xa8, /* ........ */
	}
};

View Diff

2,14c2,14
< static const unsigned char pkt1[32] = {
< 0x08, 0x60, 0x6e, 0xf1, 0x3c, 0xb9, 0x9c, 0xc7, /* .`n.<... */
< 0xa6, 0x35, 0x08, 0x12, 0x08, 0x00, 0x45, 0x00, /* .5....E. */
< 0x05, 0xdc, 0x1b, 0xe3, 0x40, 0x00, 0x31, 0x06, /* ....@.1. */
< 0xe8, 0xc8, 0xcb, 0xd9, 0x00, 0xda, 0xc0, 0xa8  /* ........ */
< };
< 
< /* Frame (32 bytes) */
< static const unsigned char pkt2[32] = {
< 0x08, 0x60, 0x6e, 0xf1, 0x3c, 0xb9, 0x9c, 0xc7, /* .`n.<... */
< 0xa6, 0x35, 0x08, 0x12, 0x08, 0x00, 0x45, 0x00, /* .5....E. */
< 0x05, 0xdc, 0x6b, 0x98, 0x40, 0x00, 0x31, 0x06, /* ..k.@.1. */
< 0x99, 0x13, 0xcb, 0xd9, 0x00, 0xda, 0xc0, 0xa8, /* ........ */
---
> static const unsigned char pkt1[2][32] = {
> 	{
> 	0x08, 0x60, 0x6e, 0xf1, 0x3c, 0xb9, 0x9c, 0xc7, /* .`n.<... */
> 	0xa6, 0x35, 0x08, 0x12, 0x08, 0x00, 0x45, 0x00, /* .5....E. */
> 	0x05, 0xdc, 0x1b, 0xe3, 0x40, 0x00, 0x31, 0x06, /* ....@.1. */
> 	0xe8, 0xc8, 0xcb, 0xd9, 0x00, 0xda, 0xc0, 0xa8  /* ........ */
> 	},
> 	{
> 	0x08, 0x60, 0x6e, 0xf1, 0x3c, 0xb9, 0x9c, 0xc7, /* .`n.<... */
> 	0xa6, 0x35, 0x08, 0x12, 0x08, 0x00, 0x45, 0x00, /* .5....E. */
> 	0x05, 0xdc, 0x6b, 0x98, 0x40, 0x00, 0x31, 0x06, /* ..k.@.1. */
> 	0x99, 0x13, 0xcb, 0xd9, 0x00, 0xda, 0xc0, 0xa8, /* ........ */
> 	}

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 207 remaining solutions by signing in and submitting your own entry
#208 Peter Lustig / @germecon - Score: 123 - 08/06/14 @ 17:46
<C-><Up><C-><Up><C-><Up><C-><Up><C-><Up><C-><Up><C-><Up><C-><Up>j\\f1ijku<Esc>ua[]2<BS>jk<BS><BS><Esc>ba2<Esc>jkoi<BS>{jj<BS><BS><Esc>jjjjjwklrqr,jdd.d5wxxxxxxx\\f}/}<CR>a<CR>}jk<BS><BS><Esc>kkkkkkkkkkkkVjjjjjjjjjjj><Esc>:wq<CR>

0 comments


Created by: @saschagrunert

208 active golfers, 713 entries

Leaderboard (lowest score wins):
26
#31 - Mike Adams / @davis_cromwell

10/11/2015 at 01:38AM

26
#32 - Jon Krause / @jkrause314

01/12/2016 at 07:38AM

26
#33 - Aleksey Zhidkov / @AlexeyZhidkov

02/24/2016 at 11:41AM

26
#34 - DHM / @DHM29978992

04/30/2018 at 12:26AM

26
#35 - Dax / @zacoxi

12/05/2018 at 05:24AM

26
#36 - Mihai / @mihaicristiant

01/03/2019 at 03:38PM

26
#37 - majo senf / @majo_senf

06/21/2019 at 03:11PM

26
#38 - Michel Viktor / @tomkpz

07/27/2021 at 04:47AM

26
#39 - Jean George / @JeanGeo20504212

01/14/2022 at 03:57PM

27
#40 - Steffen Siering / @ursobln

06/03/2014 at 09:17PM

27
#41 - Dimitar Dimitrov / @kurkale6ka

03/16/2016 at 10:54AM

27
#42 - name / @name65894813

11/28/2018 at 03:28PM

27
#43 - Lory / @Lory46845742

11/22/2019 at 12:11PM

28
#44 - Jeff / @just_geophree

03/29/2014 at 05:11PM

28
#45 - buz / @buzbone

03/29/2014 at 07:10PM

28
#46 - Petro Тrouq / @zulolosi

03/29/2014 at 10:15PM

28
#47 - Carlos López / @morrizon

03/30/2014 at 06:33PM

28
#48 - Mike Michalik / @Sh4deFM

04/01/2014 at 12:41AM

28
#49 - caguettaz / @caguettaz

04/01/2014 at 08:16AM

28
#50 - Strabs / @artistavenue

04/02/2014 at 08:07AM

28
#51 - Wojciech Razik / @WojciechRazik

04/03/2014 at 08:19PM

28
#52 - Kai Yuan / @kentyuan

04/03/2014 at 09:26PM

28
#53 - Kris Hom / @krishom

04/03/2014 at 10:40PM

28
#54 - Pedro Santos / @pedrosans

04/04/2014 at 06:43PM

28
#55 - Ricardo M. Vilchis / @ajkaanbal

04/04/2014 at 08:34PM

28
#56 - Bob Zingerman / @BobZingerman

04/08/2014 at 03:06AM

28
#57 - zhuochun / @zhuochun

04/09/2014 at 05:16PM

28
#58 - Steve Tjoa / @stevetjoa

04/30/2014 at 04:37AM

28
#59 - lastsseldon / @lastsseldon

05/09/2014 at 09:15PM

28
#60 - Leigh Bicknell / @Elwon20Leigh

05/20/2014 at 09:58PM