3

Are there any shortcuts, settings, or formatting in Visual Studio Code to remove the leading spaces where the code is written?

Usually these spaces appear when copying a certain block of code and then pasting it elsewhere, for example:

var variable1 = '';
var variable2 = '';
    var variable3 = '';
    var variable4 = '';
    var variable5 = '';

Fixed it would look like this:

var variable1 = '';
var variable2 = '';
var variable3 = '';
var variable4 = '';
var variable5 = '';
2
  • 5
    Ctrl+A and keep hold of Shift+TAB
    – rioV8
    Commented Nov 8, 2021 at 1:32
  • Works with a charm! Commented Nov 9, 2021 at 23:44

1 Answer 1

2

Actually CTRL + SHIFT + F combination fix indention automatically. It does not need any extension. Right click and then choose 'Format Document'. It will fix all kind of indention including your problem.

1
  • 1
    It is actually ALT + SHIFT + F in the latest versions.
    – Xenhat
    Commented Apr 5, 2022 at 20:28

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