如何在 sublime 构建文件中添加双引号?

How to add double quotes in sublime build file?

我想在 sublime text 3 中编译我的 C++ 程序,运行 在 cmd 中编译它。 为此,我创建了一个新的构建系统(工具-->构建系统)。

{
"cmd": ["g++", "${file}", "-o", "${file_path}/${file_base_name}"],
"file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
"working_dir": "${file_path}",
"selector": "source.c, source.c++",
"shell": "true",
"variants":
[
    {
        "name": "Run",
        "cmd": ["g++", "${file}", "-o", "${file_path}/${file_base_name}" ,"&&","start", "cmd", "/k", "$file_base_name"],
        "shell": true
    }
] }

这执行:

g++ file_location -o file_location && start cmd /k file_location

我想实现的是(这样它在执行完成后保持屏幕,并且应该在按cmd中的任意键时退出):

g++ file_location -o file_location && start cmd /c "file_location && pause>nul"

(即用 c 替换 k 并实现双引号)

我试过了\"

它没有传递 " ,而是传递了整个 \" ,这会在 cmd 中产生错误。

我该怎么办?

好的,我自己想出来了。 我应该删除 [] ,以便传递单个字符串而不是数组。现在,要使用双引号,请写 \" 而不是 "

原文:"cmd": ["g++", "${file}", "-o", "${file_path}/${file_base_name}" ,"&&","start", "cmd", "/k", "$file_base_name"]

已修改"cmd": "g++ ${file} -o ${file_path}/${file_base_name} && start cmd /c /"$file_base_name &&pause/" "