intro
-
VSCode
介绍见 github。
我用了两年半的sublime,原以为以后绝不会变心,但倒戈VSCode只用了1天。VSCode默认是可以编译运行Java代码的,但,需要移动鼠标,点击
Run
,这就很慢。 -
CodeRunner
可以运行Java,C,C++,JS等多种语言。
其实质是:绑定要一键执行的命令(cd到源代码所在的目录,编译,运行)
软件安装等
安装JDK,配置JAVA_HOME
, PATH
, CLASSPATH
环境变量。
安装VSCode的扩展CodeRunner
。
乱码
Windows环境下的cmd
采用的代码页默认编码为GBK
。
所以当源代码中有GBK不可映射字符时,会编译失败。
所以要修改CodeRunner
编译Java文件时的命令(命令行参数)。
Ctrl+Shift+P
,输入settings
。
选择>Preferences: Open Settings (JSON)
,修改JSON配置即可。
- 主要改两点:
- 编码
- 将原先的
javac 文件名
改为javac -encoding utf-8
。
- 将原先的
- 控制台输入
- 因为
CodeRunner
默认是在OUTPUT
面板输出结果,read-only
不能被编辑。
如果程序需要输入,择需在控制台console
输入。
设置:code-runner.runInTerminal: true
修改配置时注意分号,逗号等,切勿破坏JSON格式。
- 因为
- 编码
settings.json
-
默认
{ "workbench.colorTheme": "Solarized Dark+", "editor.suggestSelection": "first", "vsintellicode.modify.editor.suggestSelection": "automaticallyOverrodeDefaultValue" }
-
修改
{ "workbench.colorTheme": "Solarized Dark+", "editor.suggestSelection": "first", "vsintellicode.modify.editor.suggestSelection": "automaticallyOverrodeDefaultValue", /* code-runner.executorMap对象中是各个语言和其绑定的运行命令。 */ "code-runner.runInTerminal": true, "code-runner.executorMap": { "javascript": "node", "php": "C:\\php\\php.exe", "python": "python", "perl": "perl", "ruby": "C:\\Ruby23-x64\\bin\\ruby.exe", "go": "go run", "html": "\"C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe\"", /* 其实只要改这一行就可以 javac -encoding utf-8 $filename 指定编译源代码时采用的编码方案。 */ "java": "cd $dir && javac -encoding utf-8 $fileName && java $fileNameWithoutExt", "c": "cd $dir && gcc $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt" }, "workbench.iconTheme": "material-icon-theme", }
shortcut
Ctrl+Alt+N
运行
Ctrl+Alt+M
停止运行