0
aaa
bb|b
ccc

The text file is three lines of three characters each (cursor on the b line). How do I transform the file into

bbbaaa
ccc

I can use J to turn the above file into the follwing:

aaa
bbbccc

Right now the closest I get is something like k0Dj$p.


For context, I'm editing Uiua code that is evaluated right to left, so you can break up lines, but they need to go the opposite place you'd expect.

So if my code is

[ 1 2 3 ]
.

and I join the lines, I'd like to have the period go before the array, so the execution order is unchanged.

1 Answer 1

4

Basically, you want to swap lines before joining them. A trivial recipe is to cut and then paste back, i.e. ddkPgJ.

If you already have a key to swap lines, say [e, you can cheat a little with [egJ (or [eJ).

Also, you may want to remap J for your special filetype, so it will always join "backwards".

nnoremap <buffer>J <cmd>move--\|join!<cr>

Of course, this should go into appropriate ftplugin.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.