Skip to content
| Marketplace
Sign in
Visual Studio Code>Snippets>C/C++ Snippet ExtensionNew to Visual Studio Code? Get it now.
C/C++ Snippet Extension

C/C++ Snippet Extension

落羽行歌

|
86 installs
| (0) | Free
Code snippets for C/C++
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

C/C++ Snippet Extension

v1.1.6

该扩展为 Visual Studio Code 添加了 C/C++ 的代码片段。

This extension for Visual Studio Code adds snippets for C/C++.

用法 Usage

输入代码片段中的部分关键字,例如 "for",然后按下回车键或 tab 键。

Type a part of the keywords in snippet e.g., "for" and press enter or tab.

for // 创建一个 for 循环片段 // Creates a for loop snippet

下载 Better Comments 插件 和 Better Comments (support regex tags)插件,并添加以下代码片段到 settings.json 文件中:

Download the Better Comments plugin and the Better Comments (support regex tags) plugin, and add the following code snippet to the settings.json file:

"better-comments.tags": [
        {
            "tag": "(?<!\\|).((->)|(<-)).*40.\\|",
            "color": "#000000",
            "backgroundColor": "#FFFF88",
            "isRegex": true,
        },
        {
            "tag": "(?<!\\d).\\|",
            "color": "#000000",
            "backgroundColor": "#88FF88",
            "isRegex": true,
        },
        {
            "tag": ".*8.\\|",
            "color": "#000000",
            "backgroundColor": "#FF88FF",
            "isRegex": true,
        },
        {
            "tag": ".*12.\\|",
            "color": "#000000",
            "backgroundColor": "#88FFFF",
            "isRegex": true,
        }
    ],

更新 Update

现在看起来舒服多了,如果你需要重构一个项目或者从零开始写一个项目,请使用模板并填充内容,无需考虑繁杂的代码结构和编程规范

It looks much better now. If you need to refactor a project or start a new project from scratch, please use the templates and fill in the content without worrying about complex code structures and programming standards.

如果你需要额外的新功能,或是发现了模板存在问题,或者是有更好的模板,可以通过 GitHub 提交 issue,或者通过邮件联系我(邮箱地址:2481036245@qq.com)

If you need additional functionality, or have found issues with the templates, or have a better template, you can submit an issue through GitHub, or contact me through email.(email address: 2481036245@qq.com)

完善并修复了一部分标签,有部分内容的灵感来自于谷歌的编程规范

Improved and fixed some tags, with some content inspired by Google's programming guidelines.

预计在下次更新中添加更多现代化Cpp的内容

More modern C++ content will be added in the next update.

现在正在强制使用 UTF-8 格式和 LF 换行符,以及添加了 80 列和 120 列的提示

The current setting enforces the use of UTF-8 encoding and LF line endings, and also adds column hints for 80 and 120 characters.

添加了最新的注释代码片段:

The latest comment code snippets have been added:

增加了额外的列提示,这样你就知道你的代码的复杂度了

Added extra column hints so you can be aware of your code complexity

// 创建一个结构体切分注释 // Creates a structure split comment
//struct
// -> struct ---------------------- 40 || ? ------------------------------- 80 || ! ------------------------------ 120 |

// <- struct ---------------------- 40 || ? ------------------------------- 80 || ! ------------------------------ 120 |

// 注释缩进 4 个空格的位置 // comment indent 4 space
//4
// |

// 注释缩进 8 个空格的位置 // comment indent 8 space
//8
// - 8 |

// 注释缩进 12 个空格的位置 // comment indent 12 space
//12
// ---- 12 |

// 注释缩进 16 个空格的位置 // comment indent 16 space
//16
// -------- 16 |

// 注释缩进 20 个空格的位置 // comment indent 20 space
//20
// ------------ 20 |

安装 Installation

  1. 安装 Visual Studio Code 0.10.1 或更高版本;

    Install Visual Studio Code 0.10.1 or higher

  2. 运行 VS Code;

    Launch VS Code

  3. 输入 Ctrl+Shift+P (Windows, Linux) 或 Cmd+Shift+P (OSX);

    From the command palette Ctrl+Shift+P (Windows, Linux) or Cmd+Shift+P (OSX)

  4. 输入 ext install 或者直接选择 Install Extension;

    Type ext install or just simply select Install Extension

  5. 选择拓展 - Cpp Snippets Plus;

    Choose the extension - Cpp Snippets Plus

  6. 重启 VS Code。

    Relaunch VS Code

欢迎提出改进建议。

Suggestions for improvement are welcome.

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2025 Microsoft