VSCode一些配置问题
使用
vscode
一段时间后发现相关配置文件太多需要注意
1 修改插件地址
2 配置语言环境
2.1 通用配置
在 vscode
中安装了 code-runner
工具,点击该插件右下角 小齿轮,需要修改code-runner.executorMap
,导入编译所需要的相关文件。
或者是在 vscode
界面,同时按住 ctrl + ','(逗号)
,在弹出来的搜索设置中输入 runner.executorMap
在哪种语言那里直接指定编译器即可:
"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
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
· 一个奇形怪状的面试题:Bean中的CHM要不要加volatile?
· 分享4款.NET开源、免费、实用的商城系统
· 全程不用写代码,我用AI程序员写了一个飞机大战
· Obsidian + DeepSeek:免费 AI 助力你的知识管理,让你的笔记飞起来!
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了