VSCode一些配置问题


使用vscode一段时间后发现相关配置文件太多需要注意

1 修改插件地址

修改VSCode插件地址

2 配置语言环境

2.1 通用配置

vscode 中安装了 code-runner 工具,点击该插件右下角 小齿轮,需要修改code-runner.executorMap,导入编译所需要的相关文件。
或者是在 vscode 界面,同时按住 ctrl + ','(逗号),在弹出来的搜索设置中输入 runner.executorMap
![在这里插入图片描述]( https://img-blog.csdnimg.cn/20210702235640554.png?x-oss-process=image/watermark ,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3UwMTIwNjAwMzM=,size_16,color_FFFFFF,t_70)
在这里插入图片描述
在哪种语言那里直接指定编译器即可:

 "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 详细配置

VSCode配置C环境
VSCode配置python环境

3 VSCode配置

3.1 打开文件覆盖之前文件

VS Code IDE 界面,通过路径 文件 -> Preferences -> Settings 进入VS Code 设置或者使用Ctrl+Shfit+P
输入enablePreview(选项在Workbench工作台中)搜索,然后将箭头指示的地方的对勾取消即可,再次打开文件就不会覆盖原窗口文件了
![在这里插入图片描述]( https://img-blog.csdnimg.cn/20201026220200840.png?x-oss-process=image/watermark ,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3UwMTIwNjAwMzM=,size_16,color_FFFFFF,t_70#pic_center)

3.2 修改文件读取路径文件

由于VSCode默认执行文件是当前文件夹而不是文件,如下所示,RequestsD.py读取test.txt时,需要这样的径./python_demo/test.txt,和我们平常./test.txt是不一样的,要修改的话,就需要在使用Code Runner插件中修改
在这里插入图片描述
选中code runner后点击设置,再点击扩展设置
![在这里插入图片描述]( https://img-blog.csdnimg.cn/20210702235640554.png?x-oss-process=image/watermark ,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3UwMTIwNjAwMzM=,size_16,color_FFFFFF,t_70)
可以在插件设置中勾选File Directory As Cwd
在这里插入图片描述
勾选后,就使用如下平常./test.txt读取没问题了

3.3 Code is already running

VScode运行代码时终端tab显示:Code is already running!
解决方案:切换到输出窗口,右键,然后选择stop code run
![在这里插入图片描述]( https://img-blog.csdnimg.cn/20210708162553827.png?x-oss-process=image/watermark ,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3UwMTIwNjAwMzM=,size_16,color_FFFFFF,t_70)

3.4 快捷键设置

打开vscode快捷键有四种种方式:

3.4.1 修改代码提示

在快捷键修复窗口搜索触发建议 ,双击该条目把原来的ctrl+space修改为Alt+/,弹出框内输入快捷键,回车保存

3.4.2 修改清除输出

在快捷键修复窗口搜索clearoutput,选择视图:清除输出,双击该条目把原来的空修改为ctrl+k l,弹出框内输入快捷键,回车保存
注意ctrl+k l的按方法,先按ctrl+k,然后松开ctrl,再按l
![在这里插入图片描述]( https://img-blog.csdnimg.cn/3273d51bf66f4b9290a022ea84ba8683.png?x-oss-process=image/watermark ,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3UwMTIwNjAwMzM=,size_16,color_FFFFFF,t_70)

3.5 清除自动加入git

settings.json 里关闭自动检测仓库

{
  "git.autoRepositoryDetection": false
}

新建/打开父目录时,自动把父目录当成git 仓库打开
如果你在某个 git 仓库的子目录新建项目,VSCode 有时会关联到父级仓库:

{
  "git.openRepositoryInParentFolders": "never"
}

新文件保存时自动被 stage(加入暂存区)
如果发现新建文件后,Source Control 面板里文件直接跑到"已暂存"而不是"更改"里,检查是否开启了:

{
  "git.autoStage": false
}
posted @ 2021-07-03 10:57  上善若泪  阅读(380)  评论(0)    收藏  举报