0

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.)

  • 1
    Yeah. J joins lines, – Durga Swaroop Jul 15 '16 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 Jul 15 '16 at 17:59
6

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.

  • 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 Jul 15 '16 at 4:45
  • What effect are you referring to? The indentation issue? – Durga Swaroop Jul 15 '16 at 10:17
  • J with mulltiple lines selected joins all the lines in the selection - it gives you one VERY long line. – the_velour_fog Jul 16 '16 at 7:46
  • Yeah. That's what it is supposed to do. J joins lines. Plain and simple – Durga Swaroop Jul 16 '16 at 10:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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