Any programmer has their own favorite editor, tools, development tools, there are such a group of people, for vim such ancient artifacts difficult to control, IDE is too heavy, this time more choice vscode!!

Vscode redefines the editor. It’s open source, free and Runs everywhere. It’s a cross between an IDE and an editor. Isn’t it? 2) ㅂ•́) ✧, so you know the appearance

So what’s so great about this guy?

features

  • Microsoft development, software quality is perfect

  • High appearance level, very nice interface, allows for custom changes

  • There are so many plugins that developers are willing to embrace it

  • Friendly to my Chinese programmers, you know

  • It starts faster than Atom and consumes less resources

  • Can cross-platform features be eliminated? Can you?

  • Good support for various programming languages (of course I have only tried Java/Node/Go/Python)

  • Autocomplete, code highlighting, code jump…

  • Integration terminal easy to use, you can use code command to open files/folders

  • Debug is easy to use (almost an IDE for Mini)

  • (⊙ O ⊙) Ah! There are too many features for me to write

Having said that, you must be eager to try it. (Maybe not.

Install vscode

I know you don’t even need me to teach you how to install it, because it’s foolproof! Its website is code.visualStudio.com/, where you can download the software for your operating system.

Supports Windows, Linux, and Mac.

Understand vsccde

Why do you want to know about it? You don’t know what it’s made of, you don’t know how to use it (except high-powered ones).

layout

Here is the layout of vscode, as with most editors, divided into

  • Editor Is used to edit the body area of a file. You can open three editors side by side.

  • The Side Bar contains different browser-like views to assist in completing the project.

  • The Status Bar displays information about the currently open project and the files being edited.

  • The View Bar, on the far left hand side, helps switch views and provides additional context-specific hints, such as the number of changes to commit if Git is active.

, in my opinion, an editor is not like learning a programming language, according to a tutorial put all the function of the society, I prefer the exploratory attempt of all the things you need, such as how the five functions in the View Bar, actually point is probably understand what meaning, consult the written materials just let oneself more accurate grasp use position.

configuration

The user configuration of vscode is divided into three levels: default configuration, global configuration, and workspace configuration, with increasing priorities. For team projects, some specifications can be configured by creating a.vscode/setting.json file in the project directory, such as:

// TAB length "editor.tabSize": 2, // When enabled, trailing Spaces will be clipped when saving files. "Files. TrimTrailingWhitespace" : true, / / configure glob patterns to exclude files and folders. "files.exclude": { "**/.git": true, "**/.svn": true, "**/.DS_Store": true, "**/.idea": true },Copy the code

I usually don’t use this configuration, just user configuration, because there’s only one user on the computer anyway. Configure font size, auto save, etc.

Will install the plugin

  1. Beautify: Code highlighting

  2. Terminal: directly evokes the Terminal

  3. Project Manager: Switch between multiple projects

  4. Auto Close Tag: The Tag automatically closes (actually I think it can be built in)

How do you install it?

In the extension input box input you want to use the plug-in can, of course, it will often recommend us to the top of the plug-in, you can try to install, after the installation is finished reload the editor can be used.

Common Shortcut keys

Here are some shortcuts THAT I use frequently, but if you want to see more of them you can check out some of the shortcuts that VS Code uses

  • Copy a line Up and Down: Shift+Alt+Up or Shift+Alt+Down

  • Comment the code: CMD + /

  • Switch the sidebar: CMD + B

  • Find in folder: CMD + shift + f

  • Find the replacement: CMD + shift + h

  • Refactoring code: fn + F2

  • Format code: Shift+Alt+F, or Ctrl+Shift+P after entering Format code

Ctrl+P mode: (Mac is CMD+P)

  • Directly enter the file name, quickly open the file

  • > Displays and runs commands

  • : Jump to the number of lines, or Ctrl+G directly enter (Mac is CMD+G)

  • Jump to symbol (search variable or function) or Ctrl+Shift+O

  • @: Jump symbol according to classification, search attribute or function, also can Ctrl+Shift+O after enter: enter

  • Find symbol by name (Ctrl+T

Configuring the Java Environment

Install four Java language plug-ins

  1. Language Support for Java(TM) by Red Hat

  2. Debugger for Java

  3. Java Test Runner

  4. Maven for Java

Some people want to ask, damn, and 4 plugins, so much trouble?

What was the first plugin for? Running Java code. What about the second one? A standardized Java project must not consist of a few files. Maven is the software that builds applications in the Java environment (install it locally first).

I also need to configure java.home

"Java. Home" : "/ Library/Java/JavaVirtualMachines jdk1.8.0 _101. JDK/Contents/home".Copy the code

That’s it, now you can create an Mmp.java under VS Code and start writing Hello VS Code! .

public class Mmp { public static void main(){ System.out.println("Hello vscode!" ); }}Copy the code

Click Debug or press F5 to run the time-tested output statement. See the video at the bottom of this article for details.

The code to locate

Hold down the CTRL button and hover over the class to see the class description. Click to go to the class definition.

Code refactoring

Code refactoring

One powerful thing is that we sometimes change the names of fields and methods.

  1. Find all references: Shift + F12

  2. Modify all matches in this file at the same time: Ctrl+F12

  3. Rename: For example, if you want to change the name of a method, you can select it, press F2, type the new name, and press Enter to find that all files have been changed

  4. Jump to the next Error or Warning: When there are multiple errors, press F8 to jump to one by one

  5. View diff: Right-click the file in Explorer to Set File to compare, then right-click the file to compare with file_name_you_chose

Run the SpringBoot project

Download a sample project for SpringBoot

git clone https://github.com/JavaExamples/spring-boot-helloworld.gitcode spring-boot-helloworld
Copy the code

What? Git won’t

Launching debugging, selecting the Java language, prompts us that the launch.json file looks something like this

{// Use IntelliSense to learn about related attributes. // Hover to view descriptions of existing properties. / / for more information, please visit: https://go.microsoft.com/fwlink/?linkid=830387 "version" : "0.2.0," "configurations: [{" type" : "java", "name": "Debug (Launch)-Application<spring-boot-helloworld>", "request": "launch", "cwd": "${workspaceFolder}", "console": "internalConsole", "stopOnEntry": false, "mainClass": "hello.Application", "projectName": "spring-boot-helloworld", "args": "" }, { "type": "java", "name": "Debug (Attach)", "request": "attach", "hostName": "localhost", "port": 0 } ]}Copy the code

See mainClass for the first time and click Debug to see the console logs

Try Lombok

I don’t care if you use this guy. I like him anyway. I can use an @data annotation to automatically generate getters, setters, toString, equals, hashCode, etc. Spending more time writing these methods isn’t going to improve your ability anyway. It takes a lot more time to make changes, not at all! Will be! Want to! Okay?

According to the official documentation, I tried it. It doesn’t work in maven! It won’t work. Let me know in the comments if you can

So we installed a Lombok Annotations Support for VS Code.

Add lombok dependencies to the Maven project

< the dependency > < groupId > org. Projectlombok < / groupId > < artifactId > lombok < / artifactId > < version > 1.16.20 < / version > <scope>provided</scope></dependency>Copy the code

Give it a try

Akiko: the devil does not rebel

zhuanlan.zhihu.com/p/35176928

END

If you feel light feather articles are helpful to you, please in WeChat search and focus on “light feather IT hut” * * * * WeChat public, I will be here to share the computer information technology knowledge, theory, tools, resources, development of software is introduced, the back-end, interview, work feeling, and some thoughts of life and a series of articles. All you see and see is life. Take it slow, work hard, you and I grow together…

Phase to recommend

Multi-platform synchronization and multi-post assistant are indispensable for “we media” people

Chrome plugin recommended programmer series

Free working platform for programmers at home and abroad

20 free beautiful photo sites worth having for We Media people

A mandatory Chrome plug-in is recommended

A collection of technical web sites that programmers must have

The whole picture manipulation thing

“Like” to prove you still love me