安装VS Code:
# Ubuntu/Debian
sudo apt update && sudo apt install code
# Fedora/RHEL
sudo rpm --import https://packages.microsoft.com/keys/microsoft.asc
sudo sh -c 'echo -e "[code]\nname=Visual Studio Code\nbaseurl=https://packages.microsoft.com/yumrepos/vscode\nenabled=1\ngpgcheck=1\ngpgkey=https://packages.microsoft.com/keys/microsoft.asc" > /etc/yum.repos.d/vscode.repo'
sudo dnf install code
安装必要工具链:
# 通用开发工具
sudo apt install build-essential git curl wget
扩展:
配置:
{
"python.pythonPath": "/path/to/your/python",
"python.linting.enabled": true,
"python.linting.pylintEnabled": true,
"python.formatting.provider": "black",
"python.analysis.typeCheckingMode": "basic"
}
扩展:
配置:
{
"java.home": "/path/to/jdk",
"java.jdt.ls.vmargs": "-Xmx2G",
"java.configuration.updateBuildConfiguration": "automatic"
}
扩展:
配置:
{
"eslint.validate": ["javascript", "javascriptreact", "typescript", "typescriptreact"],
"prettier.singleQuote": true,
"javascript.updateImportsOnFileMove.enabled": "always"
}
扩展:
配置:
{
"go.gopath": "/path/to/your/gopath",
"go.useLanguageServer": true,
"go.lintTool": "golangci-lint"
}
推荐扩展:
终端配置:
配置:
{
"files.exclude": {
"**/.git": true,
"**/.svn": true,
"**/.hg": true,
"**/CVS": true,
"**/.DS_Store": true,
"**/node_modules": true,
"**/__pycache__": true
},
"search.exclude": {
"**/node_modules": true,
"**/bower_components": true,
"**/*.code-search": true
},
"editor.fontSize": 14,
"editor.tabSize": 2,
"editor.renderWhitespace": "selection",
"editor.minimap.enabled": false
}
硬件加速:
code --disable-gpu
使用Remote-SSH:
使用Dev Containers:
通用调试配置:
示例Python调试配置:
{
"version": "0.2.0",
"configurations": [
{
"name": "Python: Current File",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal"
}
]
}
Git集成:
bash
git config --global user.name "Your Name"
git config --global user.email "your.email@example.com"
推荐配置:
{
"git.enableSmartCommit": true,
"git.confirmSync": false,
"git.autofetch": true
}
常用快捷键:
自定义快捷键:
{
"key": "ctrl+shift+b",
"command": "workbench.action.tasks.build",
"when": "editorTextFocus"
}
推荐主题:
图标主题:
字体推荐:
这些配置应该能为您在Linux上使用VS Code进行后端开发提供一个强大的基础环境。根据您的具体技术栈和偏好,可以进一步调整和扩展这些配置。