vscode 下快速注释代码

VSCode Comments

In Visual Studio Code (VSCode), you can easily add comments to your code. Comments are useful for explaining code, debugging, and temporarily disabling code.

Single Line Comments

To comment a single line of code, place the cursor on the line and use the following shortcuts:

Windows/Linux: Ctrl + /

Mac: Cmd + /

Example:

# This is a single line comment in Python
print("Hello, World!")

Multi-Line Comments

To comment multiple lines of code, select the lines and use the following shortcuts:

Windows/Linux: Shift + Alt + A

Mac: Option + Shift + A

Example:

/*
This is a multi-line comment in JavaScript
console.log("Hello, World!");
console.log("This will not run");
*/

Documentation Comments

For adding documentation comments, you can use the following shortcuts:

Windows/Linux: Ctrl + Alt + t

Mac: Cmd + Alt + t

Example:

/**
* @description: This function adds two numbers
* @param {number} a - The first number
* @param {number} b - The second number
* @return {number} The sum of a and b
*/
function add(a, b) {
return a + b;
}

These shortcuts make it easy to add comments in VSCode, improving code readability and maintainability

posted @ 2025-04-29 16:46  阮柿子  阅读(185)  评论(0)    收藏  举报