【问题标题】:How to add double quotes in sublime build file?如何在 sublime 构建文件中添加双引号?
【发布时间】:2017-11-21 19:03:04
【问题描述】:

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

{
"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"

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

我试过\"

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

我该怎么办?

【问题讨论】:

  • 用引号引起来的意思是单引号吗?和双引号作为 双引号
  • 是的............

标签: c++ cmd g++ sublimetext2 sublimetext3


【解决方案1】:

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

原文:"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/" "

【讨论】:

    猜你喜欢
    • 2012-07-20
    • 2015-08-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多