Shortcut
The Problem
Consider the following poorly formatted Python code snippet:
def example_function():
print( "Hello, world!" )
print( "Code formatting is important." )
While this code would run without any issues, it doesn't look clean and can be hard to read.
The Solution
To effortlessly format your code into a more aesthetically pleasing style, we can use a convenient shortcut. In the example below, the shortcut is Option + Command + L
on my computer, but you can customize it to your liking.
def example_function():
print("Hello, world!")
print("Code formatting is important.")
How to Set Up the Shortcut
- If the default shortcut doesn't work for you, navigate to the settings and find the Keymap section.
- Search for "reformat code."
- Customize the shortcut to your preference or check the existing shortcut.
- Click "OK" to save your changes.