Repository: vscode
Issue: Shortcuts for auto indentation not working
Labels: bug,editor-autoindent


Type: <b>Bug</b>

I want to use the command `Reindent Selected Lines` or `Reindent Lines` with a shortcut. I tried setting keybindings to each of them (`Ctrl+Shift+Tab` and `Alt+I`, respectively), but when I press them in notebooks or scripts (using Python), nothing happens and the indentation is not corrected.

I have the _Black Formatter_ extension for Python. I know there is the `Format Selection` command but that changes the code too much for my liking. I only want to have things properly aligned/indented.

How can I make this shortcut work in notebook cells and scripts?

------------------------------------------------------------------------
**Troubleshooting information:**

Here is how the shortcuts look like:
![Image](https://github.com/user-attachments/assets/419db840-0ad0-473c-bcd3-e649bedb3a57)

Here is the code I am trying the shortcuts on:

```
for n in range(10):
    for r, l in zip([results1, results2],
                         ['test', 'test2']):
        a = [[1, 2, 3],
           [4, 5, 6]]
        print(n, l, r)
```

Here is the output from "Keyboard Shortcuts Troubleshooting" when pressing `Ctrl+Shift+Tab`:

```
2024-10-23 16:55:13.548 [info] [KeybindingService]: + Ignoring single modifier ctrl due to it being pressed together with other keys.
2024-10-23 16:55:36.838 [info] [KeybindingService]: / Soft dispatching keyboard event
2024-10-23 16:55:36.840 [info] [KeybindingService]: \ Keyboard event cannot be dispatched
2024-10-23 16:55:36.841 [info] [KeybindingService]: / Received  keydown event - modifiers: [ctrl], code: ControlLeft, keyCode: 17, key: Control
2024-10-23 16:55:36.841 [info] [KeybindingService]: | Converted keydown event - modifiers: [ctrl], code: ControlLeft, keyCode: 5 ('Ctrl')
2024-10-23 16:55:36.842 [info] [KeybindingService]: \ Keyboard event cannot be dispatched in keydown phase.
2024-10-23 16:55:36.857 [info] [KeybindingService]: / Soft dispatching keyboard event
2024-10-23 16:55:36.858 [info] [KeybindingService]: \ Keyboard event cannot be dispatched
2024-10-23 16:55:36.859 [info] [KeybindingService]: / Received  keydown event - modifiers: [ctrl,shift], code: ShiftLeft, keyCode: 16, key: Shift
2024-10-23 16:55:36.860 [info] [KeybindingService]: | Converted keydown event - modifiers: [ctrl,shift], code: ShiftLeft, keyCode: 4 ('Shift')
2024-10-23 16:55:36.860 [info] [KeybindingService]: \ Keyboard event cannot be dispatched in keydown phase.
2024-10-23 16:55:36.916 [info] [KeybindingService]: / Soft dispatching keyboard event
2024-10-23 16:55:36.917 [info] [KeybindingService]: | Resolving ctrl+shift+Tab
2024-10-23 16:55:36.918 [info] [KeybindingService]: \ From 1 keybinding entries, matched editor.action.reindentselectedlines, when: no when condition, source: user.
2024-10-23 16:55:36.919 [info] [KeybindingService]: / Received  keydown event - modifiers: [ctrl,shift], code: Tab, keyCode: 9, key: Tab
2024-10-23 16:55:36.919 [info] [KeybindingService]: | Converted keydown event - modifiers: [ctrl,shift], code: Tab, keyCode: 2 ('Tab')
2024-10-23 16:55:36.920 [info] [KeybindingService]: | Resolving ctrl+shift+Tab
2024-10-23 16:55:36.920 [info] [KeybindingService]: \ From 1 keybinding entries, matched editor.action.reindentselectedlines, when: no when condition, source: user.
2024-10-23 16:55:36.921 [info] [KeybindingService]: + Invoking command editor.action.reindentselectedlines.
2024-10-23 16:55:37.442 [info] [KeybindingService]: + Ignoring single modifier shift due to it being pressed together with other keys.
```

Here is the output from "Keyboard Shortcuts Troubleshooting" when pressing `Alt+I`:

```
2024-10-23 16:55:59.186 [info] [KeybindingService]: / Soft dispatching keyboard event
2024-10-23 16:55:59.201 [info] [KeybindingService]: \ Keyboard event cannot be dispatched
2024-10-23 16:55:59.201 [info] [KeybindingService]: / Received  keydown event - modifiers: [alt], code: AltLeft, keyCode: 18, key: Alt
2024-10-23 16:55:59.202 [info] [KeybindingService]: | Converted keydown event - modifiers: [alt], code: AltLeft, keyCode: 6 ('Alt')
2024-10-23 16:55:59.202 [info] [KeybindingService]: \ Keyboard event cannot be dispatched in keydown phase.
2024-10-23 16:55:59.346 [info] [KeybindingService]: / Soft dispatching keyboard event
2024-10-23 16:55:59.346 [info] [KeybindingService]: | Resolving alt+I
2024-10-23 16:55:59.347 [info] [KeybindingService]: \ From 1 keybinding entries, matched editor.action.reindentlines, when: no when condition, source: user.
2024-10-23 16:55:59.347 [info] [KeybindingService]: / Received  keydown event - modifiers: [alt], code: KeyI, keyCode: 73, key: i
2024-10-23 16:55:59.348 [info] [KeybindingService]: | Converted keydown event - modifiers: [alt], code: KeyI, keyCode: 39 ('I')
2024-10-23 16:55:59.348 [info] [KeybindingService]: | Resolving alt+I
2024-10-23 16:55:59.348 [info] [KeybindingService]: \ From 1 keybinding entries, matched editor.action.reindentlines, when: no when condition, source: user.
2024-10-23 16:55:59.349 [info] [KeybindingService]: + Invoking command editor.action.reindentlines.
2024-10-23 16:55:59.690 [info] [KeybindingService]: + Ignoring single modifier alt due to it being pressed together with other keys.
```

Here is the file I get from "Developer: Inspect Key Mappings":

```
Layout info:
{
	"name": "00000816",
	"id": "",
	"text": "Portuguese"
}

Default Resolved Keybindings (unique only):
(...)
                     ctrl+shift+Tab =>                      ctrl+shift+Tab
(...)
                     ctrl+shift+tab =>                      ctrl+shift+Tab
                              alt+i =>                               alt+I
```

-----------------------------------------------------------------------------------------------
**VS Code information:**

VS Code version: Code 1.94.2 (384ff7382de624fb94dbaf6da11977bba1ecd427, 2024-10-09T16:08:44.566Z)
OS version: Windows_NT x64 10.0.19045
Modes:
Remote OS version: Linux x64 5.15.0-122-generic

<details>
<summary>System Info</summary>

|Item|Value|
|---|---|
|CPUs|12th Gen Intel(R) Core(TM) i7-1260P (16 x 2496)|
|GPU Status|2d_canvas: enabled<br>canvas_oop_rasterization: enabled_on<br>direct_rendering_display_compositor: disabled_off_ok<br>gpu_compositing: enabled<br>multiple_raster_threads: enabled_on<br>opengl: enabled_on<br>rasterization: enabled<br>raw_draw: disabled_off_ok<br>skia_graphite: disabled_off<br>video_decode: enabled<br>video_encode: enabled<br>vulkan: disabled_off<br>webgl: enabled<br>webgl2: enabled<br>webgpu: enabled<br>webnn: disabled_off|
|Load (avg)|undefined|
|Memory (System)|15.71GB (5.40GB free)|
|Process Argv|--crash-reporter-id 725ad4c0-ed45-4564-8574-7f22af4753f0|
|Screen Reader|no|
|VM|0%|

|Item|Value|
|---|---|
|Remote|SSH: hpc|
|OS|Linux x64 5.15.0-122-generic|
|CPUs|Intel(R) Xeon(R) Gold 6234 CPU @ 3.30GHz (8 x 0)|
|Memory (System)|15.61GB (12.03GB free)|
|VM|100%|
</details><details><summary>Extensions (32)</summary>

Extension|Author (truncated)|Version
---|---|---
python-snippets|cst|0.1.2
remotehub|Git|0.64.0
vsc-python-indent|Kev|1.18.0
jupyter-keymap|ms-|1.1.2
remote-ssh|ms-|0.115.0
remote-ssh-edit|ms-|0.87.0
remote-wsl|ms-|0.88.4
azure-repos|ms-|0.40.0
remote-explorer|ms-|0.4.3
remote-repositories|ms-|0.42.0
jinja|who|0.0.8
vscode-django|bat|1.15.0
vscode-markdownlint|Dav|0.56.0
python-environment-manager|don|1.2.4
python-extension-pack|don|1.7.0
copilot|Git|1.242.0
copilot-chat|Git|0.21.2
vsc-python-indent|Kev|1.18.0
black-formatter|ms-|2024.4.0
debugpy|ms-|2024.12.0
python|ms-|2024.16.1
vscode-pylance|ms-|2024.10.1
jupyter|ms-|2024.9.1
jupyter-keymap|ms-|1.1.2
jupyter-renderers|ms-|1.0.19
vscode-jupyter-cell-tags|ms-|0.1.9
vscode-jupyter-slideshow|ms-|0.1.6
autodocstring|njp|0.6.1
indent-rainbow|ode|8.3.1
intellicode-api-usage-examples|Vis|0.2.9
vscodeintellicode|Vis|1.3.2
jinja|who|0.0.8


</details>
<!-- generated by issue reporter -->