Mickey's getting into VimGolf mode with another solution to a VimGolf Challenge. I was looking at this same challenge for a possible post but Mickey beat me too it and with a very nice strategy. The challenge is to take a multi-line list of words and transpose it. Specifically, take
ultricies, vehicula, felis, sed, auctor, aenean, euismod, semper, quam, dapibus nibh, consequat, consequat, maecenas, sit, amet, mauris, justo, quis, porttitor curabitur, pharetra, euismod, orci, sit, amet, ullamcorper, mi, tincidunt, et vitae, lorem, at, mi, feugiat, convallis, ac, eget, dui, fusce blandit, iaculis, nulla, sit, amet, dolor, nec, est, ornare, volutpat
and turn it into
ultricies nibh curabitur vitae blandit vehicula consequat pharetra lorem iaculis felis consequat euismod at nulla sed maecenas orci mi sit auctor sit sit feugiat amet aenean amet amet convallis dolor euismod mauris ullamcorper ac nec semper justo mi eget est quam quis tincidunt dui ornare dapibus porttitor et fusce volutpat
Mickey tends to concentrate more on technique than minimal keystrokes, which makes his solutions more useful outside of the narrow confines of VimGolf in Emacs. Still, it's nice to see how efficient we can be in keystrokes if only to keep those Vim people in their place. Here, then, is my solution to the problem, which follows Mickey's general strategy.
It helps to start off in an Org mode buffer because a shortcut key sequence for
org-table-convert-region is available. Unfortunately, there is not shortcut for
org-table-transpose-table-at-point but we can save a bunch of keystrokes with
|【Ctrl+x h】||mark buffer|
|【Ctrl+c |】||turn region into table|
|【Meta+<】||beginning of buffer|
|【Ctrl+Meta+%】||query regexp replace|
||replace |'s and surrounding spaces|
That's 30 keystrokes, which isn't bad. The best Vim solution was 29 (with the usual rules about not counting saving the buffer) so we're desperately in need of someone to shave off another stroke if we want to keep the Vimers from getting too smug. Of course someone could complain that
smex isn't part of stock Emacs but it really should be and since every serious Emacs user has it installed, I don't think it's breaking the rules—too much—to allow it.