Disable comment with class name in Visual Studio Code

Viewed 638

When I create a class like below:

enter image description here

Visual Studio Code adds the comment with Java class name above the class. How do I disable it? I mean I don't need this comment to be added at all.

enter image description here

2 Answers

I'm going to assume you have the Language Support for Java(TM) by Red Hat plugin installed. This seems to be the plugin that adds the class code snippet, I tried disabling it and the snippet no longer showed up.

A solution might be to write your own snippet with the class prefix that doesn't have the comment you dislike. I looked into user-created snippets in VSCode and found these useful support docs: https://code.visualstudio.com/docs/editor/userdefinedsnippets

Here's how you accomplish this:

  1. Open your command palette (Ctrl Shift P / Cmd Shift P) and search for Preferences: Configure User Snippets
  2. Search for java.json
  3. Add this JSON object to the file (within the existing brackets):
"Class": {
    "prefix": "class",
    "body": [
        "public class ${TM_FILENAME_BASE} {",
        "\t$0",
        "}"
    ],
    "description": "Public class"
}

You can change the "prefix" to anything you'd like. If you add this snippet, you'll see you now have 2 snippets when you enter the class keyword. I'm not really sure how to fix this, except for changing the prefix.

Another tip: you can change "editor.snippetSuggestions" to "top" in your settings. This will put snippets at the top of the suggestion box. (From: https://stackoverflow.com/a/40129409/3235858)

I hope this helped you!

I think you are using some extension like Powershell. Go and disable or uninstall that extension and the problem will be automatically resolved.

Do check this link.

Thanks.

Related