Book Image

Mastering PyCharm

By : Nafiul Islam
Book Image

Mastering PyCharm

By: Nafiul Islam

Overview of this book

Table of Contents (18 chapters)
Mastering PyCharm
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Snippets (live templates)


Live templates are a wonderful part of PyCharm. They are very helpful when there is a repetitive pattern that you need to type over and over again. PyCharm 3.4 introduced a couple of new snippets into the mix, so let's see how we can make our own by inspecting the snippets that are already available. Let's take a look at the main snippet that comes bundled with PyCharm 3.4:

We can see that [1] is the snippet in question and it has its own abbreviation main, and this is what we invoke with [2]. The description for snippet [3] is what will be shown when you try to invoke Insert Live Template (Command/Ctrl + J). You can change the abbreviation to suit your fancy so that you can invoke it using whatever you like. The most important parts of the screenshot to discuss are [4] and [5].

$END$ [4] is a special template variable, and it is where the cursor will be after the snippet has been inserted (after you've put in any variables that the template requires). $END$ is a...