I used ctrl+i which fixes all the indentations. Hence this fixed all the wrong spacings.