下载
插件准备
主题与图标
Atomize (Atom One Dark theme)
Material Icon Theme
前端开发
Vetur
Auto Rename Tag
macros
Java 开发
Extension Pack for Java
Lombok Annotations Support for VS Code
Spring Boot Extension Pack
KoroFileHeader (添加头部注释)
VS 配置文件
配置文件打开方式
cmd +shift + p,然后搜 Open Raw Default Settings,回车就可打开默认的 vscode 配置文件。
用户配置:点击左下角的设置齿轮,找到 settings(ctrl+,),点击右上角的 open Settings(JSON)
我全部的配置如下,你需要修改 jdk 的目录地址:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166{
//------------------------ 编辑器相关 ------------------------
"vsintellicode.modify.editor.suggestSelection": "automaticallyOverrodeDefaultValue",
"editor.suggestSelection": "first",
"editor.fontFamily": "'JetBrains Mono', Consolas, 'Courier New', monospace",
"editor.lineHeight": 22,
"editor.letterSpacing": 0.5,
"editor.cursorStyle": "line",
"editor.cursorWidth": 2,
"editor.cursorBlinking": "solid",
// 猜测字符集编码
"files.autoGuessEncoding": true,
// 每次保存的时候自动格式化
"editor.formatOnPaste": false,
//tab 代码缩进修改成 2 个空格
"editor.tabSize": 2,
// 控制编辑器是否自动格式化粘贴的内容。格式化程序必须可用,并且能针对文档中的某一范围进行格式化。
"editor.formatOnSave": false,
//图标主题
"workbench.iconTheme": "material-icon-theme",
// 编辑器颜色主题
"workbench.colorTheme": "Atomize",
// 以像素为单位控制字体大小
"editor.fontSize": 14,
// 启用或禁用字体连字。
"editor.fontLigatures": false,
// 控制字体粗细
"editor.fontWeight": "400",
// 启用/禁用导航路径
"breadcrumbs.enabled": false,
//控制编辑器在空白字符上显示符号的方式。
"editor.renderWhitespace": "boundary",
//当在 VS Code 中重命名或移动文件时,启用或禁用自动更新导入路径。要求工作区使用高于 2.9 版本的 TypeScript。always: 始终自动更新路径。
"javascript.updateImportsOnFileMove.enabled": "always",
// 用户代码片段在建议窗口小部件中的位置
"editor.snippetSuggestions": "top",
// 启用后,按下 TAB 键,将展开 Emmet 缩写。
"emmet.triggerExpansionOnTab": true,
// 控制是否在编辑器中输入时自动重命名
"editor.linkedEditing": true,
//透明度
"winopacity.opacity": 230,
//------------------------ Vue 相关 ------------------------
//关闭 Vetur 的模板验证
"vetur.validation.template": false,
// 使用 tab(制表位)缩进而非空格;
"vetur.format.options.useTabs": true,
"vetur.format.defaultFormatterOptions": {
// prettyhtml:[prettyhtml] 默认格式化
"prettyhtml": {},
// prettier:[css、postcss、scss、less、stylus、js、ts] 默认格式化
"prettier": {
"printWidth": 500, // 换行字符串阈值
},
},
//------------------------ HTML 相关 ------------------------
"liveServer.settings.fullReload": true,
"liveServer.settings.CustomBrowser": "chrome:PrivateMode",
"htmlPreview.openWith": "vscode",
//------------------------ Java 相关 ------------------------
// 如果配置的 java.home 版本低于 11,VS CODE 会提示用户安装 java 11 或以上版本的 JDK。
"java.home": "C:\\Users\\fsun7\\soft\\Java\\jdk-11",
"java.configuration.runtimes": [
{
"name": "JavaSE-1.8",
"path": "C:\\Users\\fsun7\\soft\\Java\\jdk1.8.0_202",
"default": true
},
{
"name": "JavaSE-11",
"path": "C:\\Users\\fsun7\\soft\\Java\\jdk-11",
},
],
"files.exclude": {
"**/.classpath": true,
"**/.project": true,
"**/.settings": true,
"**/.factorypath": true
},
// 配置 lombok
"java.jdt.ls.vmargs": "-noverify -Xmx1G -XX:+UseG1GC -XX:+UseStringDeduplication -Dfile.encoding=UTF-8 -javaagent:\"c:\\Users\\fsun7\\.vscode\\extensions\\gabrielbb.vscode-lombok-1.0.1\\server\\lombok.jar\"",
//------------------------ koroFileHeader ------------------------
// 函数注释
"fileheader.cursorMode": {},
// 头部注释
"fileheader.customMade": {
"Description": " ",
"author": "fulsun",
"Date": "Do not edit",
"LastEditTime": "Do not edit",
"FilePath": "Do not edit"
},
// 插件配置项
"fileheader.configObj": {
// 关闭默认添加头
"createHeader": false,
// 配置保持自动添加头
"autoAlready": true, // 默认开启
"autoAdd": true, // 自动添加头部注释开启才能自动添加
// 设置过后只有该数组里面的文件 才会自动添加头部注释
"supportAutoLanguage": [
"java"
],
"headInsertLine": {
"php": 2, // php 后缀的文件,在第二行插入文件头部注释
"*": 3, // 所有文件都在第 3 行插入注释(除了 php)
},
// 禁止。json .md 文件,自动添加头部注释
"prohibitAutoAdd": [
"json",
"md"
]
},
//------------------------ auto-rename-tag 插件 ------------------------
"auto-rename-tag.activationOnLanguage": [
"html",
"xml",
"php",
"javascript"
],
//------------------------ macros 插件 ------------------------
// 需要修改 %AppData%\Code\User\keybindings.json
"macros": {
// 插入下一行
"insertLineAfter": [
"editor.action.insertLineAfter"
],
// 添加分号并回车配置
"addSemicolonToLineEndAndThenWrap": [
"cursorLineEnd",
{
"command": "type",
"args": {
"text": ";"
}
},
"editor.action.insertLineAfter"
]
},
//------------------------ 配置终端 ------------------------
"terminal.integrated.profiles.windows": {
"MINGW32": {
"path": "C:\\Windows\\System32\\cmd.exe", //shell 路径
"icon": "terminal-cmd",
"args": [
"-defterm",
"-mingw32",
"-no-start",
"-here",
"/K chcp 936 >nul" // 指定 GBK 编码 ,UTF-8 为 65001
],
"env": {
"CHERE_INVOKING": "1",
"MSYSTEM": "MINGW32"
}
}
},
"terminal.integrated.defaultProfile.windows": "MINGW32",
"terminal.integrated.fontSize": 12,
"terminal.integrated.copyOnSelection": true,
// 始终允许不受信任的文件引入受信任的工作区,而不显示提示。
"security.workspace.trust.untrustedFiles": "open",
"redhat.telemetry.enabled": false,
"explorer.confirmDelete": true,
"explorer.confirmDragAndDrop": false
}
设置快捷键
配合 macros 实现一些快捷键
编辑文件 %AppData%\Code\User\keybindings.json
1
2
3
4
5
6
7
8
9
10
11
12[
{
"key": "shift+enter",
"command": "macros.insertLineAfter",
"when": "editorTextFocus && !editorReadonly"
},
{
"key": "ctrl+shift+enter",
"command": "macros.addSemicolonToLineEndAndThenWrap",
"when": "editorTextFocus && !editorReadonly"
}
]
代码模板
选择菜单里的 文件 > 首选项 > 用户代码片段
选择你需要自定义模板的文件,配置对应文件 json
把代码片段写在 json 里。每个代码段都是在一个代码片段名称下定义的,并且有 prefix、body 和 description。prefix 是用来触发代码片段的。使用 $1,$2 等指定光标位置,这些数字指定了光标跳转的顺序,$0 表示最终光标位置。
自动生成代码段语句网站 https://snippet-generator.app/
vue 模板
vue 模板
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104{
// Place your snippets for vue here. Each snippet is defined under a snippet name and has a prefix, body and
// description. The prefix is what is used to trigger the snippet and the body will be expanded and inserted. Possible variables are:
// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. Placeholders with the
// same ids are connected.
// Example:
// "Print to console": {
// "prefix": "log",
// "body": [
// "console.log('$1');",
// "$2"
// ],
// "description": "Log output to console"
// }
"Print to console": {
"prefix": "vue",
"body": [
"<!-- $1 -->",
"<template>",
"<div class='$2'>$5</div>",
"</template>",
"",
"<script>",
"",
"// 导入的其他文件 例如:import moduleName from 'modulePath';",
"",
"export default {",
"",
"//import 所引入的组件注册",
"components: {",
"",
"},",
"",
"data() {",
" return {",
"",
" };",
"},",
"",
"//监听属性",
"computed: {",
"",
"},",
"",
"//监控 data 中的数据变化",
"watch: {",
"",
"},",
"",
"//方法集合",
"methods: {",
"",
"},",
"",
"//生命周期 - 组件实例刚被创建",
"beforeCreate() { ",
"",
"},",
"//创建完成 访问当前 this 实例",
"created() {",
"",
"},",
"//挂载之前",
"beforeMount() { ",
"",
"},",
"//挂载完成 访问 DOM 元素",
"mounted() {",
"",
"},",
"//更新之前",
"beforeUpdate() { ",
"",
"},",
"//更新之后",
"updated() { ",
"",
"},",
"//for keep-alive 缓存功能,组件被激活时调用",
"activated() {",
"",
"},",
"//for keep-alive 组件被移除时调用",
"deactivated() {",
"",
"},",
"//组件销毁之前调用",
"beforeDestroy() {",
"",
"},",
"//组件销毁之后调用",
"destroyed() {",
"",
"},",
"}",
"</script>",
"<style lang='scss' scoped>",
"//@import url($3); 引入公共 css 类",
"$4",
"</style>"
],
"description": "Log output to console"
}
}
java 模板
常用模板
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18{
"打印字符串": {
"prefix": "sout",
"body": [
"System.out.println(\"${1:}\");"
],
"description": "打印字符串"
},
"SpringBoot 启动类": {
"prefix": "mainboot",
"body": [
"public static void main(String[] args) {",
" SpringApplication.run(${1:}.class, args);",
"}"
],
"description": "SpringBoot 启动类"
}
}
nodejs环境
nvm管理node
windows配置mirror
1
2
3D:\Users\ly\pip> nvm node_mirror https://npm.taobao.org/mirrors/node/
D:\Users\ly\pip> nvm npm_mirror https://npm.taobao.org/mirrors/npm/1
2
3
4
5
6
7
8# D:\dev\scoop\persist\nvm\settings.txt
root: D:\dev\scoop\persist\nvm\nodejs
arch: 64
proxy: none
originalpath: .
originalversion:
node_mirror: https://npm.taobao.org/mirrors/node/
npm_mirror: https://npm.taobao.org/mirrors/npm/
Python环境
修改pip镜像源
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15#~/pip/pip.ini
[global]
timeout=60
index-url=https://pypi.tuna.tsinghua.edu.cn/simple/
extra-index-url=
http://mirrors.aliyun.com/pypi/simple/
http://pypi.douban.com/simple
http://pypi.mirrors.ustc.edu.cn/simple/
[install]
trusted-host=
pypi.tuna.tsinghua.edu.cn
mirrors.aliyun.com
pypi.douban.com
pypi.mirrors.ustc.edu.cn
发布时间: 2021-05-03
最后更新: 2022-02-12
本文标题: vscode 之 Java 开发环境
本文链接: https://fulsun.github.io/post/a771.html
版权声明: 本作品采用 CC BY-NC-SA 4.0 许可协议进行许可。转载请注明出处!