vscode开发Go和Java
最新最全 vscode 插件推荐可以参考:
https://zhuanlan.zhihu.com/p/623580867
1、公共插件安装
下面是个人使用的插件:文章来源:https://www.toymoban.com/news/detail-603094.html
# 中文插件
Chinese (Simplified) (简体中文) Language Pack for Visual Studio Code
https://marketplace.visualstudio.com/items?itemName=MS-CEINTL.vscode-language-pack-zh-hans
# 主题
Quiet Light+ Theme
https://marketplace.visualstudio.com/items?itemName=ban.quietlight-plus
# 远程连接Linux服务器
Remote - SSH: Editing Configuration Files
https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-ssh-edit
# Git插件
GitLens — Git supercharged
https://marketplace.visualstudio.com/items?itemName=eamodio.gitlens
# 代码截图
Polacode
https://marketplace.visualstudio.com/items?itemName=pnp.polacode
# 使用方式
按Ctrl+Shift+p打开命令面板,然后再输入框中输入Polacode(可以自己设置成快捷键),然后将代码从左边复制到右边,保存图片即可
# 和IDEA一样的快捷键
IntelliJ IDEA Keybindings
https://marketplace.visualstudio.com/items?itemName=k--kato.intellij-idea-keybindings
# SQL管理器
SQLTools
https://marketplace.visualstudio.com/items?itemName=mtxr.sqltools
# 编程美化括号匹配
Rainbow Brackets
https://marketplace.visualstudio.com/items?itemName=tal7aouy.rainbow-bracket
# settings.json中的配置
"editor.RainbowBrackets.enabled": true,
"editor.guides.bracketPairs": "active",
"RainbowBrackets.consecutivePairColors": [
"()",
"{}",
["green", "blue"],
"Revioletd"
]
# 在VSCode里编写Markdown支持预览
Markdown Preview Enhanced
https://marketplace.visualstudio.com/items?itemName=shd101wyy.markdown-preview-enhanced
# 自动格式化代码
Prettier - Code formatter
https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode
# json美化
vscode-json
https://marketplace.visualstudio.com/items?itemName=andyyaldoo.vscode-json
# 正则表达式预览
Regex Previewer
https://marketplace.visualstudio.com/items?itemName=chrmarti.regex
# 文本排序
Sort lines
https://marketplace.visualstudio.com/items?itemName=Tyriar.sort-lines
# 预览数据文件
Data Preview
https://marketplace.visualstudio.com/items?itemName=RandomFractalsInc.vscode-data-preview
# TODO插件
TODO Highlight
https://marketplace.visualstudio.com/items?itemName=wayou.vscode-todo-highlight
Todo Tree
https://marketplace.visualstudio.com/items?itemName=Gruntfuggly.todo-tree
1、vscode开发Go
1.1 安装插件
# Go开发插件
Go
https://marketplace.visualstudio.com/items?itemName=golang.Go
1.2 在setting.json中添加配置Debug环境
{
"version": "0.2.0",
"configurations": [
{
"name": "Launch Package",
"type": "go",
"request": "launch",
"mode": "auto",
"program": "${workspaceFolder}/pkgs/client",
"dlvFlags": ["--check-go-version=false"]
}
]
}
2、vscode开发Java
2.1 安装插件
# Java开发插件
Extension Pack for Java
https://marketplace.visualstudio.com/items?itemName=vscjava.vscode-java-pack
# SpringBoot相关插件
Spring Initializr Java Support
https://marketplace.visualstudio.com/items?itemName=vscjava.vscode-spring-initializr
Spring Boot Dashboard
https://marketplace.visualstudio.com/items?itemName=vscjava.vscode-spring-boot-dashboard
Spring Boot Tools
https://marketplace.visualstudio.com/items?itemName=vmware.vscode-spring-boot
Spring Boot Extension Pack
https://marketplace.visualstudio.com/items?itemName=vmware.vscode-boot-dev-pack
# 阿里巴巴编码规约插件
Alibaba Java Coding Guidelines
https://marketplace.visualstudio.com/items?itemName=yangbaopan.vscode-java-p3c
2.2 安装JDK
# JAVA_HOME路径
D:\java\jdk
2.3 在setting.json中添加配置
"java.configuration.runtimes": [
{
"name": "JavaSE-1.8",
"path": "D:\\java\\jdk",
"default": true
},
],
2.4 插入类注释、方法注释
设置 -> 用户代码片段 -> java -> java.json
{
"Print to js class": {
"prefix": "classcomment",
"body": [
"/**",
" * ",
" * @author CJH",
" * @date ${CURRENT_YEAR}/${CURRENT_MONTH}/${CURRENT_DATE} ${CURRENT_HOUR}:${CURRENT_MINUTE}",
" */"
],
},
"Print to js method": {
"prefix": "methodcomment",
"body": [
"/**",
" * ",
" * @author CJH",
" * @date ${CURRENT_YEAR}/${CURRENT_MONTH}/${CURRENT_DATE} ${CURRENT_HOUR}:${CURRENT_MINUTE}",
" */"
],
}
}
在代码中输出 classcomment 和 methodcomment 会自动生成注释信息。文章来源地址https://www.toymoban.com/news/detail-603094.html
2.5 修改完成后自动保存文件
设置 -> 常用设置 -> Auto Save -> afterDelay
# settings.json
"files.autoSave": "afterDelay"
2.6 输出信息输出到调试控制台而非终端
# project/.vscode/launch.json
"console": "internalConsole"
{
"version": "0.2.0",
"configurations": [
{
"type": "java",
"name": "Current File",
"request": "launch",
"mainClass": "${file}"
},
{
"type": "java",
"name": "Hello",
"request": "launch",
"mainClass": "com.Hello",
"projectName": "test_2dda27c4",
"console": "internalConsole"
}
]
}
到了这里,关于vscode开发Go和Java的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!