Skip to main content

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

  1. If the default shortcut doesn't work for you, navigate to the settings and find the Keymap section.
  2. Search for "reformat code."
  3. Customize the shortcut to your preference or check the existing shortcut.
  4. Click "OK" to save your changes.