Live Templates:
Pycharm's live templates implement the ability to enter specified characters to expand into custom code snippets, improving productivity. Let's take the default main expansion for example, see the figure below, main then press ENTER to automatically expand to:
if __name__ = = ' __main__ ':
to view the system's own code extensions: file-"setting-" editor-"Live templates-" Python Python's own code snippet expansion includes Main,super, and so on, click on an item in the lower template text area can see the expanded content.
define your own code fragment: Here we take the input encode to expand to #-*-Coding:utf-8-*-for example.
From file-"setting-" editor-"Live templates-" python into the code snippet editing interface,
Steps:
1. Click on the Green Plus icon on the top right to select 1. Live Templates;
2. In Addreviation input encode, enter prompt statement in decscription: Expand to #-*-Coding:utf-8-*-
3. In template text Input #-*-Coding:utf-8-*-
4. Click Define, Tick Python
5. Click OK button to take effect.
Next we test the effect of encode expansion.
Enter encode press ENTER.
PS: The Green Box content is entered in description in step 2.