Visual Studio Code(VS code)是开发神器,通过插件配置不仅可以开发前端,还可以开发后端(java/go等),下面介绍一下vscode的常用插件与插件如何开发一个自己的插件。
git-bash
1 | #https://code.visualstudio.com/docs/editor/integrated-terminal |
nodejs
1 | #curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.34.0/install.sh | bash |
安装常用工具:
1 | npm install hexo-cli -g |
常用插件
安装以下插件: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#javascript
eslint
Color Picker
npm
Debugger for Chrome
Eclipse Keymap
#react
ES7 React/Redux/GraphQL/React-Native snippets
#vue
Vetur
Vue VSCode Snippets
#git
GitLens
zerofinance-git
#其他公共插件
Local History
XML Tools
Prettier
#https://zhuanlan.zhihu.com/p/54031899
koroFileHeader
AutoFileName
Import Cost
#java
Java Extension Pack
Spring Boot Extension Pack
Java Code Generators
Tomcat for Java
Docker
#android/ios plugin
Android iOS Emulator
React Native Tools
#see debug:https://github.com/Microsoft/vscode-react-native/blob/master/doc/debugging.md#debugging-on-ios-device
#Install ios-deploy: npm install -g ios-deploy
可以在项目的.vscode目录下添加extensions.json,并添加以下内容,当第一次打开时会提示是否需要安装这些推荐的插件:
1 | { |
可以通过命令行批量安装:
1 | #前端------ |
代码注释
koroFileHeader添加注释,在全局的settings.json中添加:
参考:
1 | "editor.fontSize": 14, |
注意:Author和LastEditors填写自己的名字
文件头注释快捷键:window:ctrl+alt+i,mac:ctrl+cmd+i
函数注释快捷键:window:ctrl+alt+t,mac:ctrl+cmd+t
常用配置
可以放在全局的settings.json中,也可以放在各个项目的settings.json中:
1 | { |
Java
https://code.visualstudio.com/docs/languages/java
https://code.visualstudio.com/docs/remote/wsl
https://code.visualstudio.com/docs/java/java-tutorial
https://code.visualstudio.com/docs/java/java-project
https://code.visualstudio.com/docs/java/java-debugging
https://code.visualstudio.com/docs/java/extensions
https://code.visualstudio.com/docs/java/java-spring-boot
插件:
1 | https://marketplace.visualstudio.com/items?itemName=vscjava.vscode-java-pack |
Settings.json
terminal.integrated.shell.windows设置为git-bash的话不能启动java项目。
1 | { |
WSL for Settings.json
1 | { |
Remote Debug:
1 | #launch.json |
Developing inside a Container
参考:
- https://code.visualstudio.com/docs/remote/containers
- https://code.visualstudio.com/docs/remote/create-dev-container
- https://code.visualstudio.com/docs/remote/containers-advanced
- https://github.com/microsoft/vscode-dev-containers
首先要安装vscode-remote-extensionpack插件:
https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.vscode-remote-extensionpack
.devcontainer/devcontainer.json
1 | // For format details, see https://aka.ms/vscode-remote/devcontainer.json or this file's README at: |
.devcontainer/Dockerfile
1 | # FROM java:8-jdk |
script.sh
1 |
|
参考以下文件:devcontainer.zip 或者:https://github.com/zhaoxunyong/java-k8s/tree/1.0.4.RELEASE/spring-k8s-feign/spring-cloud-k8s-account-service/.devcontainer
注意:
如果有变动,需要执行”Remote-Containers: Rebuild Container”。
另外不支持远程docker(2375端口)方式打开本地的目录(因为无法远程mount目录),但可以通过”Remote-Containers: Clone Repository in Container Volume”的方式或者:
If you do not have login access to the remote host, use a Docker “volume” for your source code.
Update .devcontainer/devcontainer.json as follows (replacing remote-workspace with a unique volume name if desired):
workspaceMount”: “source=employee-workspace,target=/Developer/workspace/employee,type=volume”,
If you used a volume instead of a bind mount, use Ctrl+Shift+` to open a terminal inside the container.
#You can run git clone from here to pull down your source code and use File > Open… / Open Folder… to open the cloned repository.
Docker-from-docker
.devcontainer/devcontainer.json
1 | "extensions": [ |
script.sh
1 | #https://www.cnblogs.com/763977251-sg/p/11837130.html |
插件开发
参考代码https://github.com/zhaoxunyong/vs-code-git-plugin,具体细节待补充。
参考
- https://segmentfault.com/a/1190000008968904
- https://www.cnblogs.com/virde/p/vscode-extension-input-and-output.html
- https://github.com/steveukx/git-js
- https://www.jianshu.com/p/2b096d8ad9b8
- https://github.com/Microsoft/vscode-extension-samples
- https://www.jianshu.com/p/520c575e91c3
- https://segmentfault.com/a/1190000017279102
- https://segmentfault.com/a/1190000014758981
- https://www.cnblogs.com/liuxianan/p/vscode-plugin-publish.html
- https://www.cnblogs.com/virde/p/vscode-extension-input-and-output.html
- https://www.cnblogs.com/virde/p/vscode-extension-input-and-output.html
- http://nodejs.cn/api/fs.html#fs_fs_unlinksync_path