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

VSCode中Python文件显示标尺但C/C++文件不显示的问题

解决VSCode中C/C++文件标尺不显示的问题

你的问题出在settings.json里的语言标识符错误:[C_Cpp]不是VSCode认可的C/C++语言ID,导致对应的标尺配置无法生效。Python文件的配置因为用了正确的[python]语言ID,所以能正常工作。

修正方案

将settings.json中的[C_Cpp]配置块替换为针对C和C++语言的正确配置:

{
    "C_Cpp.updateChannel": "Insiders",
    "editor.inlineSuggest.enabled": true,
    "security.workspace.trust.untrustedFiles": "open",
    "python.defaultInterpreterPath": "C:\\Path\\to\\my\\python.exe",
    "python.formatting.provider": "black",
    "[c]": {
        "editor.rulers": [80]
    },
    "[cpp]": {
        "editor.rulers": [80]
    },
    "editor.formatOnSave": true,
    "[python]": {
        "editor.defaultFormatter": "ms-python.black-formatter",
        "editor.rulers": [88]
    }
}

关键说明

  • VSCode的语言特定配置需要使用官方定义的语言ID:
    • C语言(对应.c、.C文件)的ID是c
    • C++语言(对应.cpp、.Cpp、.cxx等文件)的ID是cpp
  • 移除原配置中数组末尾的多余逗号(比如80后面的],),避免JSON语法错误

验证步骤

  1. 保存修改后的settings.json
  2. 重启VSCode或重新打开C/C++文件
  3. 查看编辑器右侧是否显示80字符位置的标尺

内容的提问来源于stack exchange,提问作者DJames

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.16 07:22:21