1

In Sublime Text 3, having multiple cursors on several lines and joining them with CMD+J results in a single line:

enter image description here

However, the same operation in VS Code (CTRL+J), results in half the number of initial lines (in this case 3 / 2 = 1.5 ≈ 2):

enter image description here

Is there a way to join all lines into one line in VS Code?

2 Answers 2

5

There is a command editor.action.joinLines which doesn't have a default keybinding. When you trigger it, you get the result you want.

{ "key": "ctrl+alt+j", // or your keybinding "command": "editor.action.joinLines" } 

No need for a cursor on the multiple lines, just select the lines you want to join and trigger the command (either with some keybinding or in the Command Palette).

Sign up to request clarification or add additional context in comments.

4 Comments

Regarding the keybinding - I've bound editor.action.joinLines to CTRL+J. But my mistake was, that I was adding the multiple cursors, instead of simple selecting all rows. Thank you very much.
Odd that the outcome is different. Doesn't seem like it should be.
In Sublime Text it isn't, but in VS Code it is.
yeah usually I also use multiple cursor and it doesn't merge all to 1 line like in sublime / intellij idea
0

select sections you want join, then ctrl+shift+j , join multi lines into one line (not multi cursor)

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.