Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VSCode: keeping indents on empty lines

Is it possible to make VSCode keep indents on empty lines?

Could not find such a setting neither natively nor in "Beautify" extension.

Example of desired behavior:

enter image description here

UPDATE: eventually I've just switched to Prettier - and never had to think about code style again as it's just being formatted automatically for me.

like image 793
Stas Korzovsky Avatar asked Dec 25 '17 12:12

Stas Korzovsky


People also ask

How do I turn on auto indent in Visual Studio?

Auto formatting settings in Visual Studio Show activity on this post. Select the text you want to automatically indent. Click menu Edit → Advanced → *Format Selection, or press Ctrl + K , Ctrl + F . Format Selection applies the smart indenting rules for the language in which you are programming to the selected text.


2 Answers

Go to File > Preferences > Settings. On the right side, add the line:

,"editor.trimAutoWhitespace": false 

It worked for me perfectly.

like image 108
Keith Fox Avatar answered Oct 09 '22 04:10

Keith Fox


Bit of an old question, but I found that a combination of the settings:

"editor.trimAutoWhitespace": false, "editor.renderWhitespace": "all" 

...worked for me.

NOTE: (19/03/2021)

It appears that this issue, registered on GitHub, is still an open case.

like image 35
Paul Avatar answered Oct 09 '22 03:10

Paul