Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to write code efficiently in VSCode

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

This article introduces you how to write code efficiently in VSCode. The content is very detailed. Interested friends can use it for reference. I hope it will be helpful to you.

Demonstrate how to write code efficiently

Some of the code has been rewritten, do you need to continue to repeat it?

The answer is no, because as long as cv is fine, is there any more elegant, more efficient and faster y ú technique than cv?

The answer is yes, that is the fast thirteen whips I created by myself.

Here's how I wrote the high-frequency (y ú) business code before I started the architecture:

I'm going to trigger the click event and create a submitted function, which occurs very frequently in the business.

Use some general function libraries in this function, then go back to the header to write the header file (the package for importing the function), and then come back to this function to continue writing unfinished logic

First whip: master shortcut key customization

The first whip is especially important, because it is the most basic knowledge of the whole shortcut key and the most important axis bone. if you don't understand it again, read it again.

Master shortcut key customization, it can enrich your operation habits, avoid shortcut key conflicts, and maintain various shortcut operation habits.

Because visual studio code shortcuts are fast and portable, you don't have to change your computer or system and worry about setting shortcuts again and again.

Open the shortcut panel

Press cmd+k cmd+s to quickly open the shortcut panel

Or call out the control panel (ctrl+shift+p) and enter the keyboard | keyboard found

Recognize the default keyboard shortcuts (JSON)

Why should I know the default keyboard shortcuts?

Because it's easy to use, you know what the unmodified keyboard mapping and keyboard shortcuts are by default.

It looks like this. It's a JSON file.

Open the keybindings.json file for shortcut keys

Open and store the user shortcut json file keybindings.json according to the dynamic diagram. As long as you modify the shortcut keys, you will have the following format

{"key": "cmd+k cmd+s", "command": "workbench.action.openGlobalKeybindings"when": "editorHasCompletionItemProvider & & textInputFocus & &! editorReadonly"}

This file is a user-defined JSON file and is in a mapping format

Key shortcut key

Shortcut key command of command vscode

Conditions under which the when command takes effect

The keybindings.json file is a json file, and your modified shortcut keys are stored here. When you change the machine, you can copy the contents of this file to another machine, and you can nice~~ it.

After all, that's what the author does.

Custom shortcut key

You can query the mapping of the shortcut key and modify the shortcut key by simply requiring the command command or the default shortcut key or directly entering the fuzzy words in the shortcut key.

For the shortcut keys used in the article, the author will provide code snippets in the following format to facilitate query.

{"key": "cmd+k cmd+a", "command": "workbench.action.openDefaultKeybindingsFile"}

[external link image transfer failed. The origin server may have hotlink protection mechanism. It is recommended to save the image and upload it directly (https://p1-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/a7b054961f614a63aee6f7dda082ec05~tplv-k3u1fbpfcp-watermark.image)]).

The second whip: positioning

Positioning is the core operation of writing code quickly, because this is a daily coding high-frequency operation, up to more than 90%, must be mastered completely, very practical.

Locate the design to the precise positioning of the code block, locate the definition of the class, locate the application, implementation, quick view, the last historical modification, set the tag somewhere, and then quickly find (vim call expert) to, and so on.

Locate line {"key": "ctrl+g", "command": "workbench.action.gotoLine"}

Scenario example: when the browser finds your file and reports an error on line 100, after finding the reason, locate it on line 100 to modify the code

On how to write code efficiently in VSCode to share here, I hope that the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report