Aligning code helps make it more readable and consistent. There are two methods to align code in Visual Studio Code: using keyboard shortcuts and auto-formatting code on saving, which we explain in this article. This guide will show you how to use keyboard shortcuts to align your code quickly.
Align code with Keyboard shortcuts
Code Alignment is available in Visual Studio Code through the following shortcuts or key combinations:
- Open the file you want to align. You’ll notice that I have an unaligned code.
Select the code you want to align and use the following shortcut:
Shift + Alt + F
Shift + Option + F
Ctrl + Shift + I