使用vscode
一段时间后发现相关配置文件太多需要注意
1 修改插件地址
2 配置语言环境
2.1 通用配置
在 vscode
中安装了 code-runner
工具,点击该插件右下角 小齿轮,需要修改code-runner.executorMap
,导入编译所需要的相关文件。
或者是在 vscode
界面,同时按住 ctrl + ','(逗号)
,在弹出来的搜索设置中输入 runner.executorMap
image.png
image.png
在哪种语言那里直接指定编译器即可:
"code-runner.executorMap": {
"javascript": "node",
"java": "cd $dir && javac $fileName && java $fileNameWithoutExt",
"c": "cd $dir && gcc $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt",
"zig": "zig run",
"cpp": "cd $dir && g++ $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt",
"objective-c": "cd $dir && gcc -framework Cocoa $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt",
"php": "php",
"python": "python -u",
"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": "runghc",
"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",
"FortranFreeForm": "cd $dir && gfortran $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt",
"fortran-modern": "cd $dir && gfortran $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt",
"fortran_fixed-form": "cd $dir && gfortran $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt",
"fortran": "cd $dir && gfortran $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt",
"sml": "cd $dir && sml $fileName"
}
2.2 详细配置
3 VSCode配置
3.1 打开文件覆盖之前文件
VS Code IDE
界面,通过路径 文件 -> Preferences -> Settings
进入VS Code
设置或者使用Ctrl+Shfit+P
输入enablePreview
(选项在Workbench
工作台中)搜索,然后将箭头指示的地方的对勾取消即可,再次打开文件就不会覆盖原窗口文件了
在这里插入图片描述
3.2 修改文件读取路径文件
由于VSCode默认执行文件是当前文件夹
而不是文件,如下所示,RequestsD.py读取test.txt时,需要这样的径./python_demo/test.txt
,和我们平常./test.txt
是不一样的,要修改的话,就需要在使用Code Runner
插件中修改
在这里插入图片描述
选中
code runner
后点击设置,再点击扩展设置在这里插入图片描述
可以在插件设置中勾选
File Directory As Cwd
在这里插入图片描述
勾选后,就使用如下平常
./test.txt
读取没问题了
3.3 Code is already running
VScode
运行代码时终端tab显示:Code is already running!
解决方案:切换到输出窗口,右键,然后选择stop code run
在这里插入图片描述
3.4 快捷键设置
打开vscode
快捷键有四种种方式:
- 左下角设置 -> 键盘快捷方式
- 左上角文件 -> 首选项 -> 键盘快捷方式
- 使用快捷键:
ctrl+k ctrl+s
- 调出命令窗口
ctrl+shift+p
-> 输入Keyboard Shortcuts
在这里插入图片描述
3.4.1 修改代码提示
在快捷键修复窗口搜索触发建议
,双击该条目把原来的ctrl+space
修改为Alt+/
,弹出框内输入快捷键,回车保存
3.4.2 修改清除输出
在快捷键修复窗口搜索clearoutput
,选择视图:清除输出
,双击该条目把原来的空修改为ctrl+k l
,弹出框内输入快捷键,回车保存
注意
:ctrl+k l
的按方法,先按ctrl+k
,然后松开ctrl
,再按l
在这里插入图片描述