【问题标题】:How to literally add newline character in vscode cpp snippet?如何在 vscode cpp 代码段中添加换行符?
【发布时间】:2020-02-12 03:52:00
【问题描述】:

如何将以下行添加到我的 vs 代码 CPP sn-p 的正文中?

#define edl '\n'

【问题讨论】:

  • 欢迎来到 SO!如果您查看how to ask 并修改您的问题,我认为您可以提高获得答案的机会。
  • 为了澄清,正如@HelloChen 在他的 sn-p 中所说,使用 '\\n' 将文字 '\n' 插入到您的输出中。所以"#define edl '\\n'",

标签: visual-studio-code code-snippets vscode-snippets


【解决方案1】:
"Print to #include <stdio.h>":{
        "scope": "c,cpp",
        "prefix": "std",
        "body": [
        "/* Hello Chen C program */",
        "#include <stdio.h>",
        "#include <stdlib.h>\n",
        "int main(void)",
        "{",
        "    ${1:printf(\"${2:Hello Chen\\n}\");}",
        "    ${3:system(\"pause\");}",
        "}",
        ],
        "description": "stdio.h"
    },

【讨论】:

    【解决方案2】:

    我很清楚你的问题,复制粘贴别忘了评分和投票

    { // 把你的sn-ps for c放在这里。每个 sn-p 都在一个 sn-p 名称下定义,并具有前缀、正文和 // 描述。前缀是用来触发 sn-p 的,并且正文将被扩展和插入。可能的变量是: // $1, $2 用于制表位,$0 用于最终光标位置,${1:label}, ${2:another} 用于占位符。占位符 // 相同的 id 已连接。 // 例子: “打印到控制台”:{ “前缀”:“jeetC”, “身体”:[

            "#include <stdio.h>",
            "#include <conio.h>",
            "#include <math.h>",
            "#include <string.h>",
            "#include <stdlib.h>",
            
            "\n",
            "int main()",
            "{   $2 ",
            "   printf(\"\\n\");",
            "   printf(\"\\n\");",
            "return 0;",
        "}",
    
        ],
        "description": "Log output to console"
    }
    

    }

    【讨论】:

      猜你喜欢
      • 2015-07-11
      • 1970-01-01
      • 1970-01-01
      • 2021-10-02
      • 1970-01-01
      • 2022-11-11
      • 1970-01-01
      • 2019-11-04
      • 2012-07-03
      相关资源
      最近更新 更多