Python IDE Configuration
The following setup generally applies to all Intellij IDE’s including Intellij IDEA, PhpStorm, WebStorm, and more. The one PyCharm-specific configuration will entail setting up the Python interpreter.
Most things listed in this post are configured in Preferences
. On MacOS, the shortcut for Preferences is Command-comma (⌘ ,
), similar to most desktop apps.
Turning Off Auto-save
Generally, the first thing I do is turn off auto-save. In most projects, I’m running a build tool/task runner (like Gulp or Webpack) which updates each time I edit a file. When everything is being recompiled, the editor will often slow down/freeze up because it’s always trying to re-index the files. In addition, unnecessary saving of files will also trigger more builds to be created. I would rather manually save the file to trigger a new build only when necessary.
Within Preferences
, go to Preferences --> Appearance & Behavior --> System Settings
. Under “Synchronization”, uncheck “Save files on frame deactivation”.
Also, I’ve found it helpful to use an asterisk to show any unsaved files. In Editor --> General --> Editor Tabs
, select the checkbox “Mark modified tabs with asterisk”. Note: when you save any unsaved file, all other unsaved files will also save.
Avoid Indexing Directories for Build and Compiled Files
In many projects, there will be certain folders which contain files you’ll never touch directly. These could be 3rd party libraries, or can be a directory set up to place compiled files. We don’t want these files to be getting indexed. Not only to they slow the IDE down because the always being overwritten, but also we don’t want them showing up in any search results.
In the Project Tool Window (which shows all the project files from the root folder), simply right-click on any directory
. Select Mark Directory As
, followed by Excluded
. The folder should turn red in the file tree.
Next and Previous Tab Shortcuts
In the other editors that I use, switching tabs can be done using the Command-Option-left or right keys ⌘ ⌥ →
. PyCharm has a separate shortcut for switching tabs that I’ve never been able to get used to. Thankfully, we can override this shortcut.
Go to Preferences --> Keymap --> Main Menu --> Window --> Editor Tabs
. Choose Select Next Tab
and enter the command and option modified keys, followed by a right arrow. You will get a warning that the shortcut has already been assigned to Main Menu –> Navigate. Since I never use the menu navigation, I simply ignore the warning. Repeat the same steps to configure the previous tab using the same modifier keys with the left arrow.
Configuring a Python Interpreter
If you need to use a version of Python which is different from your system Python, you may need to manually configure which Python interpreter to use. In may cases, PyCharm will automatically recognize if a virtual environment is set. It also keeps a running list of interpreters that have been set for other projects.
This is configured in Preferences --> Project --> Project Interpreter
. If you don’t see the path to the interpreter in the dropdown list, you can click the “Gear Icon” to add another interpreter.
Confirm Application Exit
Once in a blue moon, I’ll accidentally hit Command-Q to quit the program when I meant to hit Command-W (to close a single tab). Since I want to quit the program very rarely, I always double-check to make sure there’s a setting to confirm that I want to close the application.
This can be configured in Preferences --> Appearance & Behavior --> System Settings
. Choose the “Confirm application exit” option.
Configuring for JavaScript and ES6
Finally, in most web projects, the default JavaScript version is 5. If you are using ES6 or greater, it’s important to change the JavaScript version. Otherwise, you’ll be bombarded by errors.
Go to Preferences --> Languages & Frameworks --> JavaScript
. A dropdown should appear, with ECMAScript 6
as being one of the choices.
Posted in python