Last updated: Apr 6, 2024
Reading time·2 min
To shift a block of code to the left or the right:
Tab
to move the block of code to the right.Shift
+ Tab
to move the block of code to the left.The Tab key indents the code whereas
pressing Shift
+ Tab
moves the code to the left.
The same approach can be used to shift a single line of code left or right.
Select the line and press Tab
or Shift
+ Tab
.
If you need to select a block of code using your keyboard, press Shift
and
navigate using the arrow keys.
If you need to shift the block of code by a specific number of spaces:
Here is a short clip that shows how to select the number of spaces.
For example, if I select 1 space, pressing
Tab indents the block of code 1 space and
pressing Shift
+ Tab
moves the block of code 1 space to the left.
If you'd rather indent using tabs:
If you mess up the indentation:
Ctrl
+ Shift
+ P
on Windows and Linux.Command
+ Shift
+ P
on macOS.F1
to open the Command Palette.The option will fix the indentation in the current file.
Here is a quick clip that shows how formatting the document fixes the indentation.
You can learn more about the related topics by checking out the following tutorials: