Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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;

like image 862
leafonsword Avatar asked Jul 20 '17 03:07

leafonsword


3 Answers

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

like image 106
Alex Avatar answered Nov 20 '22 07:11

Alex


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

like image 21
leafonsword Avatar answered Nov 20 '22 07:11

leafonsword


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.

like image 1
poiucode Avatar answered Nov 20 '22 06:11

poiucode