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

199 active golfers, 691 entries

Leaderboard (lowest score wins):
26
#31 - Jon Krause / @jkrause314

01/12/2016 at 07:38AM

26
#32 - Aleksey Zhidkov / @AlexeyZhidkov

02/24/2016 at 11:41AM

26
#33 - DHM / @DHM29978992

04/30/2018 at 12:26AM

26
#34 - Dax / @zacoxi

12/05/2018 at 05:24AM

26
#35 - Mihai / @mihaicristiant

01/03/2019 at 03:38PM

26
#36 - majo senf / @majo_senf

06/21/2019 at 03:11PM

27
#37 - Steffen Siering / @ursobln

06/03/2014 at 09:17PM

27
#38 - Dimitar Dimitrov / @kurkale6ka

03/16/2016 at 10:54AM

27
#39 - name / @name65894813

11/28/2018 at 03:28PM

27
#40 - Lory / @Lory46845742

11/22/2019 at 12:11PM

28
#41 - Jeff / @just_geophree

03/29/2014 at 05:11PM

28
#42 - buz / @buzbone

03/29/2014 at 07:10PM

28
#43 - Petro Тrouq / @zulolosi

03/29/2014 at 10:15PM

28
#44 - Carlos López / @morrizon

03/30/2014 at 06:33PM

28
#45 - Mike Michalik / @Sh4deFM

04/01/2014 at 12:41AM

28
#46 - caguettaz / @caguettaz

04/01/2014 at 08:16AM

28
#47 - Strabs / @artistavenue

04/02/2014 at 08:07AM

28
#48 - Wojciech Razik / @WojciechRazik

04/03/2014 at 08:19PM

28
#49 - Kai Yuan / @kentyuan

04/03/2014 at 09:26PM

28
#50 - Kris Hom / @krishom

04/03/2014 at 10:40PM

28
#51 - Pedro Santos / @pedrosans

04/04/2014 at 06:43PM

28
#52 - Ricardo M. Vilchis / @ajkaanbal

04/04/2014 at 08:34PM

28
#53 - Bob Zingerman / @BobZingerman

04/08/2014 at 03:06AM

28
#54 - zhuochun / @zhuochun

04/09/2014 at 05:16PM

28
#55 - Steve Tjoa / @stevetjoa

04/30/2014 at 04:37AM

28
#56 - lastsseldon / @lastsseldon

05/09/2014 at 09:15PM

28
#57 - Leigh Bicknell / @Elwon20Leigh

05/20/2014 at 09:58PM

28
#58 - kwa / @kwa129

07/05/2014 at 11:25AM

28
#59 - James Scriven / @JamesDScriven

07/06/2014 at 06:58PM

28
#60 - Michael Comerford / @MComerford1

09/20/2014 at 02:45AM