I'd like to prepend the line below the current line to the current line. In other words, I want to "join" (like with J in normal mode) but instead of putting the line below the current line at the end of the current line, I'd like to put it at the front of the current line.


▋lorem ipsum amet dolor
blue green orange yellow


▋blue green orange yellow lorem ipsum amet dolor

with the position of the cursor--shown by the solid, black rectangle--at the beginning of the prepended snippet or at its end.

New contributor
chb is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
up vote 4 down vote accepted

If you don't want to use any register, you can do

:+m- | normal J

or use mapping

:nnoremap <leader>J :<c-u>+m-<cr>J

:+m- is to move the next line to be after the previous line, so eventually the order of the two lines are exchanged.

  • 1
    Clever use of the rather obscure :move command! This solution doesn't clobber the default register like DJMcMayhem's. – Ingo Karkat Nov 9 at 7:19
  • Using :+m- to replace ddpk has one more benefit: it can be undone using a single u. But it cannot be repeated using . (ddpk cannot be repeated using . either) – Liu Sha Nov 9 at 7:38

Just swap the lines before you join them:


Of course, if you would like to override J's behavior, you could map this with:

:nnoremap J ddpkJ

or if you want a new mapping so that you have both options:

:nnoremap <leader>J ddpkJ

Your Answer

chb is a new contributor. Be nice, and check out our Code of Conduct.

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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