通用设置

Auto Save:afterDelay

explorer.autoReveal:false

Font

  • Font Family:JetBrains Mono

  • Font Size:15(根据显示器调节大小)

  • Integrated:Font Size:16

Tab Size:4

debug.console.fontSize:17(根据显示器调节大小,要相对较大一些比较舒服)

Open Mode:doubleClick

  • Smooth Scrolling

快捷方式

workbench.explorer.fileView.focus:Alt + 1(资源管理器: 焦点在文件夹视图上)

workbench.action.terminal.toggleTerminal:Alt + 2(查看: 切换 终端)

workbench.view.debug:Alt+3(查看: 显示 运行和调试)

outline.focus:Alt+4(资源管理器: 焦点在大纲视图上)

editor.action.formatDocument:Ctrl+Alt+L(格式化文档)

workbench.action.files.openFile:Alt+O(文件: 打开文件...)

workbench.action.files.openFolder:Alt+B(文件: 打开文件夹...)

workbench.action.toggleSidebarVisibility:Alt + `(查看: 切换主侧栏可见性)

workbench.action.terminal.clear:ScrollLock(终端: 清除)

editor.action.triggerSuggest:Alt+/(触发建议)

editor.action.triggerParameterHints:Alt+Shift+/(触发参数提示)

editor.toggleFold:Ctrl+j(切换折叠)

editor.toggleFoldRecursively:Alt+Shift+j(以递归方式切换折叠)

通用插件

Chinese (Simplified) (简体中文) Language Pack for Visual Studio Code: Language pack extension for Chinese (Simplified)

CodeGeeX: AI Code AutoComplete, Chat, Auto Comment:AI-based coding assistant, which can suggest code in the current or following lines

扩展设置:

  • Codegeex.CompletionModel:CodeGeeX Pro

Error Lens: Improve highlighting of errors, warnings and other language diagnostics.

GBK to UTF8 for vscode: Convert file encoding from gbk to utf8 for vscode

Hex Editor: Allows viewing and editing files in a hex editor

Hungry Delete: To delete an entire block of whitespace or tab, and reduce the time programmers need to press backspace

Markdown All in One: All you need to write Markdown (keyboard shortcuts, table of contents, auto preview and more)

Prettier - Code formatter: Code formatter using prettier

Path Intellisense: Visual Studio Code plugin that autocompletes filenames

IntelliCode: AI-assisted development

Code RunnerRun code snippet or code file for multiple languages

  • 进入Executor Map的settings.json,在python中添加如下命令解决中文乱码问题:

    • Windows:set PYTHONIOENCODING=utf8 && & \"$pythonPath\" -u $fullFileName

    • Linux:set PYTHONIOENCODING=utf8 && \"$pythonPath\" -u $fullFileName

  • 开启code-runner.runInTerminal

  • 开启code-runner.fileDirectoryAsCwd

在运行参数中,Code Runner的自定义参数有

  • $workspaceRoot: The path of the folder opened in VS Code

  • $dir: The directory of the code file being run

  • $dirWithoutTrailingSlash: The directory of the code file being run without a trailing slash

  • $fullFileName: The full name of the code file being run

  • $fileName: The base name of the code file being run, that is the file without the directory

  • $fileNameWithoutExt: The base name of the code file being run without its extension

  • $driveLetter: The drive letter of the code file being run (Windows only)

  • $pythonPath: The path of Python interpreter (set by Python: Select Interpreter command)

ANSI Colors:ANSI color styling for text documents

Remote - SSH: Open any folder on a remote machine using SSH and take advantage of VS Code's full feature set.

Docker:Makes it easy to create, manage, and debug containerized applications.

Eclipse Keymap: Eclipse keybindings for Visual Studio Code

驼峰翻译助手:中文一键翻译转换成常用大小驼峰等格式(也支持多种格式)

Data Wrangler:Data viewing, cleaning and preparation for tabular datasets

主题插件

Material Icon Theme: Material Design Icons for Visual Studio Code

JetBrains Mono. A typeface for developers​_: JetBrains Mono font pack - OpenSource monospaced font with programming ligatures vscode extension

Python配置

设置

python.analysis.inlayHints.callArgumentNames:partial(python函数形参提示)

python.analysis.diagnosticMode:workspace(用于显示诊断的分析范围)

模块

Python: IntelliSense (Pylance), Linting, Debugging (multi-threaded, remote), code formatting, refactoring, unit tests, and more.

Pylance: A performant, feature-rich language server for Python in VS Code

Python Environment Manager: View and manage Python environments & packages.

Python Indent: Correct Python indentation

Jinja: Jinja template language support for Visual Studio Code

yapfFormatter support for python files using yapf

autoDocstring - Python Docstring Generator: Generates python docstrings automatically

Quick-Python-Print: Quickly handle print operations : Insertion(include print out variable, variable type, tensor shape etc), (Un)comment, Delete by using shortcuts

snippets设置

生成器:snippet generator (snippet-generator.app)

教程:VSCode 利用 Snippets 设置超实用的代码块 - 掘金 (juejin.cn)

打开snippets设置:文件 -> 首选项 -> 用户代码片段

个人配置:

	"generate_main": {
		"prefix": ".main",
		"body": [
			"if __name__ == '__main__':",
			"    "
		],
		"description": "generate_main"
	},
	"generate_header": {
		"prefix": ".header",
		"body": [
	    	"# -*- coding: utf-8 -*-",
			// "# @Time    : $CURRENT_YEAR-$CURRENT_MONTH-$CURRENT_DATE $CURRENT_HOUR:$CURRENT_MINUTE",
			"# @Time    : $CURRENT_YEAR-$CURRENT_MONTH-$CURRENT_DATE",
			"# @Author  : $1",
			"# @File    : $TM_FILENAME",
			"# @Software: VSCode",
			"# @Example : ",
			"# @Description: ",
		],
		"description": "generate_header"
	},

launch.json

python

设置python模块运行

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "运行当前窗口选择的python文件",
            "type": "debugpy",
            "request": "launch",
            "program": "${file}",
            "console": "integratedTerminal",
            "justMyCode": true,
            "env": {
                "PYTHONPATH": "${workspaceFolder}"
            }
        }
    ]
}

下面是各个字段的解释:

  • version: 指定 launch.json 文件的版本,通常由 VSCode 自动管理。

  • configurations: 一个数组,包含了一个或多个调试配置对象。

在每个配置对象中:

  • name: 配置的名称,它将出现在 VSCode 的调试配置下拉菜单中。

  • type: 调试器的类型。对于 Python,这通常是 "python"。(新版本vscode已改成debugpy

  • request: 请求类型,通常是 "launch",表示启动一个新的调试会话;或者是 "attach",表示附加到一个已经运行的进程上进行调试。

  • program: 要调试的程序的路径。对于 Python 脚本,你可以使用 "${file}",这是一个变量,表示当前打开的文件。

  • console: 调试控制台的类型。对于 Python,常见的选项有 "integratedTerminal"(在 VSCode 的集成终端中运行程序)和 "internalConsole"(在 VSCode 的内置调试控制台中运行程序)。

  • justMyCode: 一个布尔值,当设置为 true 时,调试器将只显示用户代码,而隐藏标准库和第三方库的代码。这有助于减少调试时的噪音。

此外,还有一些其他可选的配置项,例如:

  • args: 传递给程序的命令行参数数组。

  • cwd: 工作目录,即程序运行时所在的目录。默认情况下,它是 ${workspaceFolder},即你的工作区目录。

  • env: 一个对象,用于设置环境变量。例如:{"PYTHONPATH": "${workspaceFolder}"}

  • debugOptions: 用于指定调试选项的数组。

文章作者: Vsoapmac
版权声明: 本站所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 soap的会员制餐厅
其他 个人分享 bug记录
喜欢就支持一下吧