Scripting console
The IDE Scripting Console can be used to write simple scripts that automate PyCharm features and extract various information. With access to the IntelliJ Platform API, you can think of it as a lightweight alternative to a plugin, which adds or modifies some behavior of the IDE.
By default, it supports scripts written in JavaScript and Groovy. However, you can use any scripting language that is compliant with JSR 223, for example, Python, Ruby, Clojure, and so on.
Some information and examples are available in this gist.
Open the IDE Scripting Console
Press Control+Shift+A and type
IDE Scripting Console
. Once the required option is located, click it to run the console.This opens the IDE Scripting Console tab in the editor, where you can type code and execute it using Control+Enter.
The scripts are stored in the Configuration directory under consoles/ide. You can also see them in the Project tool window under Scratches and Consoles/IDE Consoles. If you add a file named .profile followed by the designation of the corresponding language to this directory (for example, .profile.groovy), it will be executed along with any script that you run. Use the profile to define functions for your scripts.