How to make vscode compact multiple lines to a single line?

Visual Studio-CodeKeyboard Shortcuts

Visual Studio-Code Problem Overview


I have 4 lines like this in vscode:

> 1 line;
> 2 line;
> 3 line;
> 4 line;

Does vscode have a shortcut that can quickly compact 4 lines to 1 line like this:
> 1 line; 2 line; 3 line; 4 line;

Visual Studio-Code Solutions


Solution 1 - Visual Studio-Code

Select your code => F1 => "Join Lines"

You can also create a keyboard shortcut for this command editor.action.joinLines

Default shortcut on Mac is Ctrl+J

Solution 2 - Visual Studio-Code

It seems vscode's "Join Lines" keyboard shortcut in macOS is ctrl + j:
enter image description here

Solution 3 - Visual Studio-Code

Or you could use these two in vs code.

Fold multiple lines: ctrl + shift + [ Unfold multiple lines: ctrl + shift + ]

I prefer these because I want to use prettier as well.

Solution 4 - Visual Studio-Code

I also had same issue and solved it. If you use Prettier, try it as below.

Settings -> Prettier.printWidth" 

The default value is 80. If you change this value higher than 80.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionleafonswordView Question on Stackoverflow
Solution 1 - Visual Studio-CodeAlexView Answer on Stackoverflow
Solution 2 - Visual Studio-CodeleafonswordView Answer on Stackoverflow
Solution 3 - Visual Studio-CodeHyeonminView Answer on Stackoverflow
Solution 4 - Visual Studio-CodepoiucodeView Answer on Stackoverflow