目录
vscode整理
最近把开发环境从sublime转到了vs code上,sublime被墙真难受,天天和防火墙斗智斗勇,vscode就好一些了。
vs code主要的还是一些插件与配置,我主要用python和C++,因此主要整理了这两个语言的常用插件。
PS,不推荐安装中文插件~
插件
主题图标
- vscode-icons,图标插件
- Material Theme, 老牌主题插件
- Monokai Dark Vibrant,monokai dark主题,颜色很鲜艳 (推荐)
- One Dark Pro, Atom's iconic One Dark theme (推荐)
代码通用
- Code Runner, 支持各种语言的运行(
Ctrl+Alt+N
) - All Autocomplete,从打开文件中生成自动补全
- Prettier-Code formatter, 代码规范化
- YAML, YAML支持
- indent-rainbow, 缩进加强显示,我主要用python,感觉不用也没事
- leetcode, 刷题必备
工具
- SFTP, 远程文件同步
- Shell,脚本
- File Utils, 文件夹相关操作
markdown
- Markdown all in one
- markdownlint
python
- Python,必须的
- Python for vscode,必须的
- Anaconda Extension Pack,使用的Anaconda必备
C++
- C++ 必备
- C++ intellisense, 必备
- Cmake Tool, 必备
Git
- GitLens
- Git History
- Git Blame
- Git Project Manager
Latex
快捷键
窗口与文件
- side bar: Ctrl+B
- 打开关闭控制窗口 Ctrl+~
- 编辑区打开文件页面切换: Ctrl+Tab,或Ctrl+PageUp, Ctrl+PageDwon
- 从控制窗口返回编辑区,Ctrl+Tab选择文件,或者Ctrl+~关闭控制端
- 窗口分栏, Ctrl +
- 新建文件, Ctrl + N
- 打开文件, Ctrl + P
- 关闭文件, Ctrl + W
- 新建窗口, Ctrl + Shift + N
- 关闭在整窗口: Ctrl + Shift + W
代码与光标
- 上下移动页面: Ctrl+(uparrow), Ctrl+(downarrow)
- 左右按单词移动光标: Ctrl+( ightarrow), Ctrl+(leftarrow)
- 移动到文件开头和结尾: Ctrl + Home, Ctrl + End
- 减少/增加缩进: Ctrl + [,Ctrl + [
- 选中多个相同字符串同时编辑: Ctrl + D
- 代码格式化: ubuntu: Ctrl + Shift + I, win: Alt+Shift+F
查找与替换
- 当前文件查找或替换, Ctrl + F, Ctrl + H
- 全局文件查找或替换, Ctrl + Shift + F, Ctrl + Shift + H
文件配置
全局文件配置
在Ubuntu上,全局配置位于~/.config/Code/User/setting.json
文件中,我目前的配置为:
{
"cmake.configureOnOpen": true,
"explorer.confirmDelete": false,
"terminal.integrated.shell.linux": "/bin/bash",
"editor.suggestSelection": "first",
"python.jediEnabled": false,
"terminal.integrated.inheritEnv": false,
"gitlens.views.repositories.location": "gitlens",
"gitlens.views.fileHistory.location": "gitlens",
"gitlens.views.lineHistory.location": "gitlens",
"gitlens.views.compare.location": "gitlens",
"gitlens.views.search.location": "gitlens",
"workbench.preferredDarkColorTheme": "One Dark Pro",
"workbench.preferredHighContrastColorTheme": "One Dark Pro",
"workbench.preferredLightColorTheme": "One Dark Pro",
"workbench.colorTheme": "One Dark Pro",
"workbench.iconTheme": "vscode-icons",
}
项目文件配置
项目文件配置位于项目文件夹下的.vscode文件中,主要有
- setting.json:项目的配置
- task.json:要作用就是执行类似
gcc -g main.c -o main
的命令,用于编译生成 - launch.json: 以配置VS Code以在按F5调试程序
- sftp.sjon: SFTP模块的配置
python
- setting.json
{
"python.pythonPath": "/home/willer/anaconda3/bin/python",
"python.linting.enabled": true,
"python.linting.pylintEnabled": false,
"python.linting.flake8Enabled": true,
"python.formatting.provider": "autopep8",
}
- launch.json
{
// 使用 IntelliSense 了解相关属性。
// 悬停以查看现有属性的描述。
// 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Python: 当前文件",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal"
}
]
}
- tasks.json
{
"version": "2.0.0",
"tasks": [
{
"label": "python",
"type": "shell",
"command": "/home/willer/anaconda3/bin/python",
"args": [
"${file}"
],
"group": {
"kind": "build",
"isDefault": true,
}
}
]
}
C++
我用vs code开发C++项目比较少,主要是用Clion。这里可能会有不对的地方。
- c_cpp_properties.json
{
"configurations": [
{
"name": "Linux",
"includePath": [
"${workspaceFolder}/**"
],
"defines": [],
"compilerPath": "/usr/bin/clang-4.0",
"cStandard": "c11",
"cppStandard": "c++11",
"intelliSenseMode": "clang-x64",
"compileCommands": "${workspaceFolder}/build/compile_commands.json"
}
],
"version": 4
}
- launch.json
// 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "(gdb) Launch",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/hello", // 修改输出程序路径
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": true,
"preLaunchTask": "build_hello", // 添加 "preLaunchTask" 编译任务
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
]
}
- task.json
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "build_hello", // 与launch的"preLaunchTask"一致
"type": "shell",
"command": "make", // 使用 makefile
"problemMatcher": {
"owner": "cpp",
"fileLocation": [
"relative",
"$workspaceRoot"
],
"pattern": {
"regexp": "^(.*):(\d+):(\d+):\s+(warning|error):\s+(.*)$",
"file": 1,
"line": 2,
"column": 3,
"severity": 4,
"message": 5
}
},
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
SFTP
{
"name": "rc",
"protocol": "sftp",
"host": "132.XXX.XXX.XXX",
"username": "root",
"password": "xxxxxx",
"port": 22,
"uploadOnSave": false,
"downloadOnOpen": false,
"watcher": {
"files": "**/*",
"autoUpload": true,
"autoDelete": true
},
"ignore": [
"node_modules",
".vscode",
".idea",
".DS_Store"
],
"remotePath": "/www/XXXX"
}
在工作区排除指定文件
在.vscode/setting.json文件中可以按照如下方式指定排除文件
"files.exclude": {
"**/.git": true,
"**/.svn": true,
"**/.hg": true,
"**/CVS": true,
"**/.DS_Store": true,
"**/*.db": true,
"**/datasets": true
}