I know these commands in Vim:
J : Join line below after current line
-J : Join current line after line above
but how do I join the line above after current line?
You can also use the ex-command
:m-2|j
m-2
has the effect of moving the current line to 2 lines above its current position; this switches the position of the current line and the line above.j
joins the current line and the line above, inserting a space between the two. Use j!
if you don't want the space.|
separates the 2 ex-commandsThis ex-command is a short way of writing the following
:move .-2
:join
There are many ways to do it. One would be… deleting the line above and appending it to the end of the line below:
k move up one line
^ move to the first printable character
y$ yank to the end of the line
"_d get rid of the now useless line by deleting it into the black hole register
$ move to the end of the line
p put the deleted text
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With