You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Python脚本与Notebook中Reindent系列快捷键失效问题求助

问题:Reindent命令快捷键在Python脚本和Notebook中无效

我想给Reindent Selected Lines和Reindent Lines命令设置快捷键来修正代码缩进,已经完成快捷键配置,但在Python脚本和Notebook单元格中按下快捷键时完全无效,代码缩进没有被修正。

我了解Format Selection命令,但它会过度修改代码,不符合我的需求——我仅需要实现代码的对齐与缩进修正。

如何让这些快捷键在Notebook单元格和脚本中正常工作?


排查信息

快捷键配置截图

快捷键配置截图

测试代码

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)

按下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.

按下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.

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

内容的提问来源于stack exchange,提问作者João Bravo

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.17 01:44:53