Visual Studio中有实现C和C++基本结构的捷径吗?
Is there any shortcut in Visual Studio that implements basic structure of C and C++?
本身,在Visual Studio代码中,有一个创建HTML基本结构的快捷方式(或者emmet,不知道是不是这样叫的)。输入感叹号并按 TAB 键会带来我们开始构建 Web 应用程序时需要编写的所有代码。
但是,我正在 Visual Studio Community 2019 中寻找类似的快捷方式,它为 C 中的基本应用程序提供了起始代码。
例如,
include <stdio.h>
include <stdlib.h>
int main(){
return 0;
}
P.S。 : 我知道并非每个应用程序都运行相同的起始模板,或者它们甚至没有起始模板。但是,我作为一个新手,一直在上面写这个结构,这有点像一个入门模板。
在无知地低估投票之前,花足够的时间理解答案。
C 代码段没有开箱即用的快捷方式。
但是,您可以创建自己的代码片段或从市场安装此扩展程序。
名称:C 代码段
ID:harry-ross-software.c-snippets
说明:C 编程语言的片段
版本:1.3.0
出版商:Harry Ross Software
VS 市场 Link:https://marketplace.visualstudio.com/items?itemName=Harry-Ross-Software.c-snippets
click to see image example
您可以同时按 ctrl+space 查看所有可用的片段
This page 解释了如何创建您自己的片段
这些是 macOS 上的步骤:
- Select User Snippets under Code > Pereferences
- Select C 语言
- 在 JSON 文件中创建代码段
生成程序基本结构的片段可能如下所示:
{
"Skeleton": {
"prefix": "main",
"body": [
"#include <stdio.h>",
"#include <stdlib.h>",
"",
"int main(void)",
"{",
"\t${1:code}",
"\treturn 0;",
"}",
""
],
"description": "Dummy C program skeleton"
}
}
这是它的样子:
本身,在Visual Studio代码中,有一个创建HTML基本结构的快捷方式(或者emmet,不知道是不是这样叫的)。输入感叹号并按 TAB 键会带来我们开始构建 Web 应用程序时需要编写的所有代码。
但是,我正在 Visual Studio Community 2019 中寻找类似的快捷方式,它为 C 中的基本应用程序提供了起始代码。
例如,
include <stdio.h>
include <stdlib.h>
int main(){
return 0;
}
P.S。 : 我知道并非每个应用程序都运行相同的起始模板,或者它们甚至没有起始模板。但是,我作为一个新手,一直在上面写这个结构,这有点像一个入门模板。
在无知地低估投票之前,花足够的时间理解答案。
C 代码段没有开箱即用的快捷方式。 但是,您可以创建自己的代码片段或从市场安装此扩展程序。
名称:C 代码段 ID:harry-ross-software.c-snippets 说明:C 编程语言的片段 版本:1.3.0 出版商:Harry Ross Software VS 市场 Link:https://marketplace.visualstudio.com/items?itemName=Harry-Ross-Software.c-snippets
click to see image example
您可以同时按 ctrl+space 查看所有可用的片段
This page 解释了如何创建您自己的片段
这些是 macOS 上的步骤:
- Select User Snippets under Code > Pereferences
- Select C 语言
- 在 JSON 文件中创建代码段
生成程序基本结构的片段可能如下所示:
{
"Skeleton": {
"prefix": "main",
"body": [
"#include <stdio.h>",
"#include <stdlib.h>",
"",
"int main(void)",
"{",
"\t${1:code}",
"\treturn 0;",
"}",
""
],
"description": "Dummy C program skeleton"
}
}
这是它的样子: