VSCode format on save adding additional tabs in Solidity files

Solution 1:

The vscode-solidity extension uses Prettier for formatting(link)

To achieve formatting with 2 spaces:

  1. Create a file .prettierrc
  2. The contents should be
    {
       "overrides":[
          {
             "files":"*.sol",
             "options":{
                "tabWidth":2
             }
          }
       ]
    }
  1. Restart VS code