近期在使用 Github Copilot 時,發現在面對 NES (Next Edit Suggestions) 補全時,按下 Tab 鍵經常會出現空格,而非跳轉到目標位置,經過一番排查,發現這是因為 VSCode 的 Tab 鍵綁定衝突導致的,本文記錄下解決方法。
錯誤表現#
在使用 Github Copilot 進行代碼補全時,按下 Tab 鍵並沒有跳轉到補全建議的位置,而是插入了空格,導致無法順利接受補全建議,如下圖:
調試思路#
首先我們啟動 VSCode 的鍵盤快捷鍵調試功能,按下Ctrl + Shift + P搜索shortcut troubleshooting,打開快捷鍵調試面板。
發現類似下方的信息:
2025-10-18 15:58:06.749 [info] [窗口] [KeybindingService]: / Received keydown event - modifiers: [], code: Tab, keyCode: 9, key: Tab
2025-10-18 15:58:06.749 [info] [窗口] [KeybindingService]: | Converted keydown event - modifiers: [], code: Tab, keyCode: 2 ('Tab')
2025-10-18 15:58:06.749 [info] [窗口] [KeybindingService]: | Resolving Tab
2025-10-18 15:58:06.749 [info] [窗口] [KeybindingService]: \ From 14 keybinding entries, matched tabout, when: editorTextFocus && !editorHasMultipleSelections && !inSnippetMode && !inlineSuggestionVisible && !suggestWidgetVisible, source: user extension albert.TabOut.
2025-10-18 15:58:06.749 [info] [窗口] [KeybindingService]: + Invoking command tabout.
顯然,Tab 鍵被TabOut插件佔用了。
解決方法#
此時我們可以使用Ctrl + K Ctrl + S打開鍵盤快捷鍵設置,搜索"Tab",找到TabOut: Tab Out,點擊右側的垃圾桶圖標刪除該快捷鍵綁定。
不過也有更好的辦法,就是為 TabOut插件設置一個條件,使其在 Github Copilot 補全建議出現時不生效。我們可以將其when條件末尾追加!inlineEditIsVisible條件,最終得到該條件editorTextFocus && !editorHasMultipleSelections && !inSnippetMode && !inlineSuggestionVisible && !suggestWidgetVisible && !inlineEditIsVisible (編輯後按回車保存)。
現在,就能夠正常補全了:
結束後重新按下Ctrl + Shift + P搜索shortcut troubleshooting以關閉快捷鍵調試面板。