
经过了半年的打磨,Code Runner已经支持了 27 种语言: C, C++, Java, JS, PHP, Python, Perl, Ruby, Go, Lua, Groovy, PowerShell, BAT/CMD, BASH/SH, F#, C#, Vbscript, TypeScript, CoffeeScript, Scala, Swift, Julia, Crystal, OCaml, R, AppleScript, Elixir 。并且支持以下几个主要功能:

如果大家发现了任何 bug 或者有什么建议,欢迎来GitHub给我提 issue 或者 PR 。
最近还开通了"玩转VS Code"的公众号。希望能和大家分享一下VS Code使用和开发的一些经验,主要希望提供的内容包括但不限于:
有兴趣的童鞋,可以来关注"玩转VS Code"公众号。也希望听听大家的意见,更希望看到什么样的内容。 
1 langmoe 2017-01-14 12:39:19 +08:00 我还以为买的 Code Runner 又有更新了。。 |
2 chairchan 2017-01-14 13:55:30 +08:00 via Android 兹词 正在用 |
3 KiriGiri 2017-01-14 13:57:52 +08:00 via Android 可以添加一个功能,把运行结果直接替换选中的代码,就像 vim 的:'<,'>!command 。 |
4 asxaqz 2017-01-14 14:10:40 +08:00 一直在用。支持。 |
5 0915240 2017-01-14 15:27:31 +08:00 我曹 ! 兹词~~ |
6 40huo 2017-01-14 16:03:30 +08:00 兹词,好用! |
7 cdwyd 2017-01-14 16:39:50 +08:00 python 的输出不是实时的吗?测试了下是全部执行完才统一输出 |
8 quericy 2017-01-14 16:42:11 +08:00 厉害了,已安装 |
9 exoticknight 2017-01-14 16:45:05 +08:00 好厉害,是不是应该换了…… |
10 kchum 2017-01-14 17:12:10 +08:00 我也以为是 Code Runner 2 。。 |
11 loading 2017-01-14 17:44:25 +08:00 via Android 比 vs go 是不是强一些呢,看看。 |
12 pipecat 2017-01-14 19:46:38 +08:00 via iPhone 在用,支持 |
13 formulahendry OP |
14 formulahendry OP @KiriGiri VIM 没怎么用过,能具体说下吗?比如说,运行 var a = 1 + 2 ,然后把代码替换为 var a = 3? |
15 blanu 2017-01-14 21:44:47 +08:00 via iPhone Great! VSCode 自带的调试运行时太重,这个看上去就非常方便 |
16 formulahendry OP @blanu 对滴!而且能选择运行 code snippet ,快捷轻巧 |
17 XYxe 2017-01-14 22:08:06 +08:00 Python 输出的中文会乱码 另外,不能区分 Python2 和 Python3 吗? |
18 formulahendry OP @XYxe 关于乱码,有两个解决方法: 1. 设置 PYTHONIOENCODING ,参考 https://github.com/formulahendry/vscode-code-runner/issues/33#issuecomment-263131627 "code-runner.executorMap": { "python": "set PYTHOnIOENCODING=utf8 && python" } 2. 设置使用 built-in terminal ,参考 https://github.com/formulahendry/vscode-code-runner/issues/25#issuecomment-257123682 "code-runner.runInTerminal": true 关于区分 Python2 和 Python3 ,可以在 user settings 自定义 code-runner.executorMap ,参考 https://github.com/formulahendry/vscode-code-runner#configuration |
19 XYxe 2017-01-14 22:55:45 +08:00 @formulahendry 啊,谢谢 。不能把 Python2 和 3 设置为不同语言吗?因为不同的文件可能需要不同版本, 每次修改设置会比较麻烦。 |
20 formulahendry OP @cdwyd 唉, python 真的有这个问题唉,其他语言倒是能实时输出的不过有办法可以 workaround ,在 user settings 设置使用 ntegrated Terminal : "code-runner.runInTerminal": true |
21 cdwyd 2017-01-14 23:07:12 +08:00 via Android @formulahendry 明天试试这个,开启那个 repl 也能解决 |
22 viko16 2017-01-14 23:18:17 +08:00 via Android 好棒,赞赞赞 |
23 formulahendry OP |
24 cdwyd 2017-01-14 23:28:36 +08:00 @formulahendry 忽略上一条吧 专门起来看了下就是用的"code-runner.runInTerminal": true |
25 Lattez 2017-01-14 23:31:01 +08:00 赞赞赞!!自己配的话太麻烦,每次开个新的都要重新弄 |
26 XYxe 2017-01-14 23:33:37 +08:00 @formulahendry 可以通过 shebang 来判断吗? |
27 formulahendry OP @XYxe 目前对文件类型的判断是直接调用 VS Code 的 API , VS Code 并没有对 python 2 和 python 3 有区分。而且 shebang 在 Windows 上并没有吧。不过可以考虑当作个 feature 来做。欢迎到 github 给我提这个 feature ,如果你想自己实现的话,也非常欢迎 PR ! |
28 formulahendry OP @cdwyd 哈哈哈 |
29 Lxxyx 2017-01-15 00:09:14 +08:00 via Android 刚试了试,感觉很棒,谢谢楼主。 |
30 kuaner 2017-01-15 02:46:02 +08:00 via iPhone 哈哈,原来作者在这呀,非常棒的插件 |
31 anuxs 2017-01-15 07:58:53 +08:00 via iPhone 支持。试试。 |
32 DearMark 2017-01-15 09:22:54 +08:00 via Android 32 个赞\()/ |
33 KiriGiri 2017-01-15 10:06:33 +08:00 |
34 visitantzj 2017-01-15 12:26:25 +08:00 |
35 formulahendry OP @KiriGiri 很有意思的功能!可以考虑实现下! |
36 formulahendry OP @visitantzj 对!运行单个小文件非常方便! |
37 xuboying 2017-01-15 12:55:30 +08:00 via iPhone 这个要具体语言的运行库么,还是楼主的云上运行? |
38 hxtheone 2017-01-15 13:09:40 +08:00 这个必须赞 |
39 renyiqiu 2017-01-15 13:12:25 +08:00 mark 一下 |
40 formulahendry OP @xuboying 对的,需要相应的解释器或编译器。比如 JS 需要 Node , C 需要 gcc 。当然也可以根据需要自己设置,比如可以用 clang 替换 gcc 。 |
41 icreeper 2017-01-15 14:07:01 +08:00 感觉比 CodeRunner2 还好用!赞一个 |
42 formulahendry OP |
43 manongvpn 2017-01-16 07:53:22 +08:00 via Android 大牛 |
44 araraloren 2017-01-16 09:30:09 +08:00 看起来不错的样子,最近也有点使用 VSCODE 的兴趣~~ mark 一下 |
45 coa 2017-01-16 22:14:08 +08:00 这个强, Code Runner 2 胜在支持 Objective C ,可惜收费。。求问 Atom 下有没有类似的东西。。。 |
46 WeeH9T 2017-02-07 11:05:59 +08:00 @formulahendry vs2015 没找到 CTRL+P ,怎么安装。。。 |
47 formulahendry OP @hambut 这个插件是 Visual Studio Code 的: https://code.visualstudio.com/ ,不是 VS IDE |
48 WeeH9T 2017-02-07 14:47:00 +08:00 @formulahendry #47 好尴尬啊。。刚才下了 VS CODE 试了下,别的都挺满意, CTRL SHIFT O 有些认不出来,没有 minimap 暂时性流失。。 |
49 formulahendry OP @hambut 看什么语言了吧, Node.js 有 built-in 支持,其它语言的'Go to Symbol'还是要另外装插件 |
50 vito0719 2017-05-11 16:02:12 +08:00 能在 windows 下运行 swift 吗? |
51 formulahendry OP @vito0719 Bash on Windows :) |
52 vito0719 2017-05-12 18:13:52 +08:00 @formulahendry 我在 bash 里已经可以用 swift 了,请问在 vs code 里还需要改什么? |
53 formulahendry OP @vito0719 1. 设置 Integrated Terminal 用 Bash on Ubuntu (on Windows): https://code.visualstudio.com/docs/editor/integrated-terminal#_windows:"terminal.integrated.shell.windows": "C:\\Windows\\sysnative\\bash.exe" 2. 设置 Code Runner 用 Integrated Terminal:"code-runner.runInTerminal": true |
54 formulahendry OP |
55 vito0719 2017-05-15 15:15:03 +08:00 @formulahendry 好像问题是路径?我运行得到的回复是这样的: Playground.swift"-CZZ:/mnt/c/Users/vito0719$ swift "c:\Users\vito0719\Documents\ <unknown>:0: error: no such file or directory: 'c:\Users\vito0719\Documents\Playground.swift' 好像要改成 /mnt/c/Users/这样的路径才行,这个有方法吗? |
56 formulahendry OP @vito0719 的确目前有 limitation,现在有 issue 在 track: https://github.com/formulahendry/vscode-code-runner/issues/106 |
57 jin7 2017-07-22 23:53:52 +08:00 @formulahendry 嗨~. 我发现 powershell 中文乱码了. ps1 文件, 编码是 ucs2-le, 代码页是 1200 设置 ``` "code-runner.runInTerminal": true, "code-runner.executorMap": { "powershell": "chcp 1200>nul && powershell -ExecutionPolicy ByPass -File" } ``` 输出是一行乱码: Ч 设置成 chcp 65001 可以输出, 只是中文当作 ansi 编码解析了. 为什么我要把 ps1 文件保存为 ucs2-le 编码, 因为, powershell 好像不认 utf8 编码, 中文会乱码. 用 ucs2-le 就没事. |
58 jin7 2017-07-23 11:13:21 +08:00 我发现 chcp 1200 为无效代码页. 但是我把文件保存为 utf8, 并且设置如下, 也没有用 ``` "code-runner.runInTerminal": true, "code-runner.executorMap": { "powershell": "chcp 65001>nul && powershell -ExecutionPolicy ByPass -File" } ``` |
59 bestswifter 2018-03-11 17:21:12 +08:00 可否把 runCustomCommand 命令和 run 命令的快捷键设置为同一个呢? 我有一个需求是,如果没有指定 customCommand,就按照 executorMap 里面的配置来执行,如果有 customCommand,则优先执行 customCommand。 我知道 keybindings.json 里面有一个 when 字段,但是不知道该填什么值 |