How to align the Sublime Text code

Easily align code in Sublime Text with this example: Select lines, right-click, choose "Align By" and you're done!

Aligning Code in Sublime Text

Sublime Text provides a great way to align code, making it easier to read and debug. With the use of the "Alignment" package, you can easily align all of your code in Sublime Text. To use the package, select the lines you want to align, then press the keyboard shortcut for the "Alignment" package. This will align all of the code based on the position of the cursor.

The following example shows how to align the following code using the "Alignment" package:

var firstName = 'John';
var lastName = 'Smith';
var age = 25;
var gender = 'male';
var job = 'teacher';

To align this code, select all of the lines, then press Alt+Ctrl+A (or Cmd+Ctrl+A on Mac). After pressing the shortcut, the code will be aligned as follows:

var firstName = 'John';
var lastName  = 'Smith';
var age       = 25;
var gender    = 'male';
var job       = 'teacher';

Using the "Alignment" package can save time when writing code and make it easier to read. It is highly recommended to use this package for any code you write in Sublime Text.

Answers (0)