我使用 Visual Studio Code 作为我的代码编辑器。我在谷歌上进行了搜索,但找不到任何关于我的问题的信息。
问题很简单,在编辑器中按 ⇥ Tab 什么也不做。我期待它插入4个空格。
任何人都知道我可以做些什么来让 ⇥ Tab 像预期的那样工作?
我使用 Visual Studio Code 作为我的代码编辑器。我在谷歌上进行了搜索,但找不到任何关于我的问题的信息。
问题很简单,在编辑器中按 ⇥ Tab 什么也不做。我期待它插入4个空格。
任何人都知道我可以做些什么来让 ⇥ Tab 像预期的那样工作?
按 ctrl+M 会导致 ⇥ Tab 键移动焦点,而不是插入 ⇥ Tab 字符。
再次按快捷方式将其关闭。
File > Preferences > Keyboard Shortcuts
。toggle tab key moves focus
。Remove Keybinding
。在我的案例中,我遵循 this advice 并将 vscode 中的此 emmet 设置更改为 false
:
"emmet.triggerExpansionOnTab": false
我收到错误 Cannot read property 'value' of null
。它立即解决了问题。
截至 2018 年 12 月,在使用 VSCode 1.29.1 的 macOS Mojave 10.14.2 上,“切换 Tab 键移动焦点”的默认键绑定设置为 Command+Shift+M
。如果您对此感到困惑,使用该组合键应该可以解决问题。
如果要更改组合键,请执行 Command+K Command+S
以调出热键设置,然后搜索 Toggle Tab Key Moves Focus
或 editor.action.toggleTabFocusMode
。
我在 xfce 上使用代码 - 执行以下操作来修复 Tab 键行为:
文件 -> 首选项 -> 设置
搜索 “keyboard.dispatch”
复制到右侧面板并将值从“code”更改为“keyCode”
重新加载代码
[Edit] This answer is for MSVS (the IDE, as opposed to VS Code
). It seems Microsoft and Google go out of their way to choose confusing names for new products. I'll leave this answer here for now, while I (continue to) look for the equivalent stackoverflow question about MSVS
. Let me know in the comments if you think I should delete it. Or better, point me to the MSVS
version of this question.
I installed MSVS 2017 recently. None of the suggestions I've seen fixed the problem. The solution I figured out works for MSVS 2015 and 2017. Add a comment below if you find that it works for other versions.
Under Tools -> Options -> Text Editor -> C/C++ -> Formatting -> General, try unchecking the "Automatically indent when I type a tab" box. It seems counter intuitive, but it fixed the problem for me.
我不小心为 Tab 键启用了不同的模式。通过按 Cmd+Shift+M(对于 Mac)或 Ctrl+M(对于 Windows)修复它。
来自 Visual Studio Code Keybinding docs :
当前选项卡控制模式也应该显示在状态栏中: