Is it possible to make a line of script (print("\033c")) fixed in VsCode (python language)?

Problem: 

Is it possible to make a line of script (print("\033c")) fixed in VsCode (python language)?

In order to remove file path displayed in Terminal of VsCode I use print("\033c")  at the first line of each script file. I wonder is it possible to make this line be the first line of each script file by default?

Solution:

Yes, it's possible to make print("\033c") the default first line in each new Python file in VS Code. You can achieve this by creating a code snippet in VS Code.


Here are the steps to create the code snippet:

1) Open VS Code and go to "File" -> "Preferences" -> "User Snippets".

2) Select "python.json" to create a new Python snippet file.

3) Add the following code to the "python.json" file:


{

    "Print Clear": {

        "prefix": "clear",

        "body": [

            "print('\033c')",

            "$1"

        ],

        "description": "Print Clear"

    }

}


4) Save the "python.json" file.

5) Now, whenever you create a new Python file, you can type "clear" and press the "Tab" key to insert the print("\033c") line at the beginning of the file.

Note that you can customize the snippet prefix, body, and description as per your preference.

Comments