How to easily add todo in vscode?

In Visual Studio Code (VSCode), there are many ways to easily add TODO comments:

1. Simple comments

TODO:You can add comments starting with directly in your code . For example:

// TODO: Add error handling

2. Use shortcut keys

You can set a custom shortcut key to quickly insert TODO comments. To do this, you need to edit keybindings.jsonthe file ( Preferences: Open Keyboard Shortcuts (JSON)opened with the command) and add the following:

{
    
    
  "key": "ctrl+alt+t",
  "command": "editor.action.insertSnippet",
  "args": {
    
    
    "snippet": "// TODO: $1"
  }
}

Ctrl+Alt+TThis way, VSCode will automatically insert it when you press // TODO: .

3. Use extensions

There are several VSCode extensions that can help you manage TODO items more efficiently, such as:

  • Todo Tree: This extension displays a TODO list in the sidebar.
  • TODO Highlight: This extension highlights TODO comments in your code.

4. Use code snippets

You can also create a custom code snippet to insert TODO comments. To do this, you need to open Preferences: Configure User Snippets, select the appropriate language (or create a global snippet), and add the following:

"Insert TODO": {
    
    
  "prefix": "todo",
  "body": [
    "// TODO: $1"
  ],
  "description": "Insert a TODO comment"
}

This way, when you type in the editor todoand press Tabthe key, VSCode will insert it // TODO: .

The above are several methods for adding TODO comments in VSCode. You can choose the method that suits you best according to your needs.

Guess you like

Origin blog.csdn.net/m0_57236802/article/details/133042282
Recommended