5

I accidentally discovered that the key combination will concatenate the current line and the next line. However, I do not recall it being mentioned in the quickref. After a quick Google, I did not find anything. Do any have a clue about where in the documents can I find more about this key combination?

BTW, I have confirmed that this is not mapped in the :map.

Update:

With the help from a comment, (Curiously, I saw it in a message. But after I opened the website, it disappeared.) I found that I am actually using the <shift-j>, i.e. <J> key to join lines. Thanks to this post.

Update 2:

J in visual mode provides extra capabilities. See :help v_J. (Thanks to @Antony's comment.)

3
  • 2
    Yeah. J joins lines, Commented Jul 15, 2016 at 3:57
  • See :help v_J . Prefix Visual mode commands with v_ to find them in the documentation. This is explained at :help.
    – Antony
    Commented Jul 15, 2016 at 17:59
  • the help command led me to gJ, which doesn't add spaces ♥️
    – redbmk
    Commented Aug 12, 2020 at 17:11

1 Answer 1

9

I am guessing you were holding the Shift key even while pressing j. Because V + j alone would not have concatenated the lines.

V is for selecting the entire line.

j moves the selection down.

So, this is not the combination that did that for you.

V + J on the other hand does exactly that. (holding shift for v and j)

J here joins the current line to next line (J for Join), which is a default setting in Vim.

You will get the same functionality without having to press V. Press J in normal mode and it will Join the next line with the current line.

For more info, try help :join in Vim.

4
  • As a side note, using V to select multiple lines will cause a different effect than just doing J. It just happens to be the same with only one line.
    – DJMcMayhem
    Commented Jul 15, 2016 at 4:45
  • What effect are you referring to? The indentation issue? Commented Jul 15, 2016 at 10:17
  • J with mulltiple lines selected joins all the lines in the selection - it gives you one VERY long line. Commented Jul 16, 2016 at 7:46
  • Yeah. That's what it is supposed to do. J joins lines. Plain and simple Commented Jul 16, 2016 at 10:03

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.