万千只cnm 发表于 2021-7-18 13:25:08

vs code 怎么配置编译器呀

怎么样才能直接运行呀
网上查了好多都不行

王逗比666 发表于 2021-7-18 13:33:28

vs code本质上是文本编辑器,要当IDE用要搭配额外的编译器,这个小甲鱼应该有视频:https://www.bilibili.com/video/BV1nt4y1r7Ez

kogawananari 发表于 2021-7-18 13:51:11

windows我可以帮弄mac没玩过

kogawananari 发表于 2021-7-18 13:56:17

说一下原理下载code runner插件之后可以给任意后缀的语言配置命令 但是这个命令必须有stdout或者stderr
如果你给markdown文件配置一个typora命令 是打不开的 因为它没std输出

settings.json默认配置如下

"code-runner.clearPreviousOutput": true,
    //"code-runner.runInTerminal": true,   注意这个 你如果要使用stdin比如c语言的getchar函数 就得开启这个
    "code-runner.executorMap": {
      "javascript": "node",
      "java": "cd $dir && javac $fileName && java $fileNameWithoutExt",
      "c": "cd $dir && gcc $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt",    //这个就是你编译并运行c的命令gcc你先得有效
      "cpp": "cd $dir && g++ $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt",
      "objective-c": "cd $dir && gcc -framework Cocoa $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt",
      "php": "php",
      "python": "set PYTHONIOENCODING=utf8 && python",
      "perl": "perl",
      "perl6": "perl6",
      "ruby": "ruby",
      "go": "go run",
      "lua": "lua",
      "groovy": "groovy",
      "powershell": "powershell -ExecutionPolicy ByPass -File",
      "bat": "cmd /c",
      "shellscript": "bash",
      "fsharp": "fsi",
      "csharp": "scriptcs",
      "vbscript": "cscript //Nologo",
      "typescript": "ts-node",
      "coffeescript": "coffee",
      "scala": "scala",
      "swift": "swift",
      "julia": "julia",
      "crystal": "crystal",
      "ocaml": "ocaml",
      "r": "Rscript",
      "applescript": "osascript",
      "clojure": "lein exec",
      "haxe": "haxe --cwd $dirWithoutTrailingSlash --run $fileNameWithoutExt",
      "rust": "cd $dir && rustc $fileName && $dir$fileNameWithoutExt",
      "racket": "racket",
      "scheme": "csi -script",
      "ahk": "autohotkey",
      "autoit": "autoit3",
      "dart": "dart",
      "pascal": "cd $dir && fpc $fileName && $dir$fileNameWithoutExt",
      "d": "cd $dir && dmd $fileName && $dir$fileNameWithoutExt",
      "haskell": "runhaskell",
      "nim": "nim compile --verbosity:0 --hints:off --run",
      "lisp": "sbcl --script",
      "kit": "kitc --run",
      "v": "v run",
      "sass": "sass --style expanded",
      "scss": "scss --style expanded",
      "less": "cd $dir && lessc $fileName $fileNameWithoutExt.css"
    }

不会起名字的我 发表于 2021-7-18 14:13:56

Visual Stidio Code是个编辑器,需要插件

万千只cnm 发表于 2021-7-18 18:32:14

王逗比666 发表于 2021-7-18 13:33
vs code本质上是文本编辑器,要当IDE用要搭配额外的编译器,这个小甲鱼应该有视频:https://www.bilibili.co ...

{:5_106:}

万千只cnm 发表于 2021-7-18 18:33:02

kogawananari 发表于 2021-7-18 13:56
说一下原理下载code runner插件之后可以给任意后缀的语言配置命令 但是这个命令必须有stdout或者stderr
...

{:5_104:}

kogawananari 发表于 2021-7-18 19:10:02

万千只cnm 发表于 2021-7-18 18:33


说白了就是你gcc命令得有效   就像是你运行python需要python命令有效 运行js需要node命令有效

你gcc有效就能运行c和cpp了当然vscode不支持输入windows下ps1命令不支持&&符号导致开启runInTerminal也会报错要修改配置 关掉runInTerminal后还得改回&&{:10_292:}
页: [1]
查看完整版本: vs code 怎么配置编译器呀