6.1.10. Smart Tab KeyΒΆ

Pressing the Smart Tab key will indent to the next “logical indentation” column on the line. It does so by inserting spaces, but only the required number of spaces are inserted so that this next position is reached, rather than always inserting a fixed number of spaces.

The “logical indentation” columns are determined by the numeric “Default indentation” preference on the Coding Style preference page. The first “logical indentation” position is at column 1. Each subsequent position is calculated by adding the value of the “Default indentation” preference to the previous position.

The Smart Tab Key is enabled by default and is controlled by the “Use smart tab key” preference on the Editor preference page.

If the preference is disabled, pressing the tab key will insert the number of spaces specified by the “Default indentation” preference.

For the following example, assume the “Default indentation” value is 3. As a result, the logical indentation positions are 1, 4, 7, 10, and so on.

In this first figure the cursor is on column 1. We have included a comment indicating the column numbers for the sake of illustration:

smart tab key example column 1

Pressing the Smart Tab key indents to column 4:

smart tab key example column 4

If we enter a space character, the cursor will then be on column 5.

smart tab key example column 5

Pressing the Smart Tab key again now inserts only two spaces to get to the next “logical indentation” column, i.e., column 7:

smart tab key example column 7

Pressing the Smart Tab key again inserts three spaces to get to column 10:

smart tab key example column 10