Home > Back-end >  Is there any way to autoload the PyGame skeleton in VS Code?
Is there any way to autoload the PyGame skeleton in VS Code?

Time:09-27

I recently started learning with PyGame and I'm getting tired of writing the basic skeleton over and over again. Is there any way to make Visual Studio Code autoload the skeleton for me?

For example in HTML, when you write an exclamation mark (!) and then press the tab key, it autoloads the basic HTML skeleton.

Would be OK for me, if there was any built-in way to do this. But it would be even better, if I could define the skeleton by myself (because I like to put comments there and I'm used to a particular order of the skeleton) and then connect it to some shorcut or something.

CodePudding user response:

Code snippets may be useful to you.

Code snippets are templates that make it easier to enter repeating code patterns, such as loops or conditional-statements.

enter image description here

  • Choose python in the list

    enter image description here

  • At this time, vscode will automatically create a file named python.json. There you can customize code snippets.

    A small example

    code in ``python.json`

        "Print to console": {
            "prefix": "defHello",
            "body": [
                "def Hello():",
                "${1:    }print('Hello world')",
                "$2",
            ],
            "description": "print hello world"
        }
    

    When you type def..., there will be a corresponding intellisense

    enter image description here

    Enter to select, automatically insert the statement you configured.

    enter image description here

    • Related