Editor basics | PyCharm (2023)

The PyCharm editor is the main part of the IDE that you use to create, read and modify code.

The editor consists of the following areas:

Editor basics | PyCharm (1)
  1. The scrollbar shows errors and warnings in the current file.

  2. Breadcrumbs help you navigate inside the code in the current file.

  3. The gutter shows line numbers and annotations.

  4. Tabs show the names of the currently opened files.

Navigation

You can use various shortcuts to switch between the editor and different tool windows, change the editor size, switch focus, or return to the original layout.

Maximize editor pane

  • In the editor, press Control+Shift+F12. PyCharm hides all windows except the active editor.

    You can maximize a split screen as well. In this case, the active screen is maximized, and other screens are moved aside.

Switch the focus from a window to the editor

  • Press Escape. PyCharm moves the focus from any window to the active editor.

Return to the editor from the command-line terminal

  • Press Alt+F12. PyCharm closes the terminal window.

  • If you need to keep the terminal window open when you switch back to the active editor, press Control+Tab.

Jump to the last active window

  • Press F12.

Use the switcher for navigation

  1. To jump between the opened files and tool windows with the switcher, press Control+Tab.

  2. Keep Control pressed to leave the switcher popup open.

  3. Press Tab to move between elements. Press Backspace to remove the selected file from the list and close it in the editor.

Change the IDE appearance

You can switch between schemes, keymaps, and viewing modes.

  1. Press Control+`.

  2. In the Switch menu, select the option you need and press Enter. Use the same shortcut Control+` to undo your changes.

You can adjust the color scheme settings, including the High contrast color scheme for people with eyesight deficiency, in Settings | Editor | Color Scheme. To adjust the keymap settings, go to Settings | Keymap.

Jump to the navigation bar

  • Press Alt+Home.

When you work with code in the editor, PyCharm displays code analysis results that include errors and warnings on the scrollbar. You can check whether your code has issues and quickly navigate to them.

The top of the scrollbar has the Inspections widget that gives you a brief summary of the code problems. Click the widget to get more information on each detected problem in the Problems tool window.

Editor basics | PyCharm (2)

For more information, refer to Instant analysis of the current file.

The stripes on the scrollbar indicate places where PyCharm found a problem. Hover over a stripe to see a tooltip describing the problem, or click the stripe for quick navigation.

It is normal to see many stripes while you are working on a file. Many of these errors, warnings, and suggestions are eventually resolved as you complete the code. Should any errors remain when you feel your code is complete, we recommend that you explore and resolve them before compiling your project.

The different colors of stripes indicate the severity of the problems from an error marked in red to a TODO comment marked in blue, but you can change the displayed colors if you need. For more information, refer to Change inspection severity.

Editor tabs

You can close, hide, and detach editor tabs. Every time you open a file for editing, a tab with its name is added next to the active editor tab.

To configure the settings for editor tabs, use the Settings | Editor | General | Editor Tabs page. Alternatively, right-click a tab and select Configure Editor Tabs from the list of options.

Open or close tabs

  • To close all opened tabs, select Window | Editor Tabs | Close All Tabs from the main menu.

  • To close all inactive tabs, press Alt and click Editor basics | PyCharm (3) on the active tab. In this case, only the active tab stays open.

  • To close all tabs except the active one and the pinned tabs, right-click any tab and select Close Other Tabs.

  • To close only the active tab, press Control+F4. You can also click the mouse's wheel button anywhere on a tab to close it.

  • To reopen the closed tab, right-click any tab and select Reopen Closed Tab from the context menu.

  • To open a new tab and place it to the right of all opened tabs, select Open new tabs at the end in the tab settings.

Copy path or filename

  1. Right-click the tab.

  2. From the list that opens, select Copy Path/Reference….

  3. From the list that opens, select your copy option.

    Editor basics | PyCharm (4)

    PyCharm copies the item to the clipboard, and you can paste it (Control+V) wherever you need.

Move, remove, or sort tabs

  • To move or remove the Editor basics | PyCharm (5) icon on a tab, in the Settings dialog (Control+Alt+S), go to Editor | General | Editor Tabs, and select the appropriate option in the Close button position field.

  • To place the editor tabs in a different part of the editor frame or hide the tabs, right-click a tab and select Configure Editor Tabs to open the Editor Tabs settings. In the Appearance section, select the appropriate option from the Tab placement list.

  • To see hidden editor tabs, click Editor basics | PyCharm (6) next to the last visible tab in the editor.

  • To sort the editor tabs alphabetically, right-click a tab and select Configure Editor Tabs to open the Editor Tabs settings. In the Tab order section, select Sort tabs alphabetically.

Pin or unpin a tab

You can pin an active editor tab so that it stays open when the tab limit is reached or when you use the Close Other Tabs command.

  • To pin or unpin an active tab, right-click it and select Pin Tab or Unpin Tab from the context menu.

  • To close all tabs but the pinned ones, right-click any tab and select Close All but Pinned.

  • To assign a keyboard shortcut for the Pin Tab action, in the Settings dialog (Control+Alt+S), go to Keymap, find the Pin Active Tab action, right-click it, select Add Keyboard Shortcut, and press the key combination you want to use.

  • To keep pinned tabs on the left side, in the Settings dialog (Control+Alt+S), go to Advanced Settings, locate the Editor Tabs section, and select the Keep pinned tabs on the left option.

Detach a tab

When you detach a tab, the tab opens in a separate window, and the window becomes reserved for the detached tab.

If you try to detach another tab from the main frame, it will be opened in the window with the already detached tab. You can position the newly detached tab anywhere you like (on the left, right, bottom, or top). You can also drag different tool windows to that frame.

  • Drag the tab you need outside the main window. If you want to re-attach the tab, drag it back over the main window.

  • To detach an active tab, press Shift+F4.

  • You can also use Alt for the same action.

Switch between tabs

  • To move between tabs, press Alt+ArrowRight or Alt+ArrowLeft.

  • You can also switch between recently viewed tabs or files.

    In the editor, press Control+Tab and keep holding Control to keep the Switcher window open. Use Tab to select the necessary tab or file.

Assign a shortcut for the opened tab

  1. In the Settings dialog (Control+Alt+S), go to Keymap.

  2. In the list of directories, click Other and select the directory for which you want to add a shortcut. The maximum number of tabs to which you can assign shortcuts is 9.

    Editor basics | PyCharm (7)

Change the default tab limit

PyCharm limits the number of tabs that you can open in the editor simultaneously (the default tab limit is 10).

  1. In the Settings dialog (Control+Alt+S), go to Editor | General | Editor Tabs.

  2. In the Closing Policy section, adjust the settings according to your preferences and click OK.

Open files in the preview tab

The preview tab allows you to view files in a single tab one by one without opening each file in a new tab. This is helpful if you need to look through several files without exceeding the tab limit.

  1. In the Project tool window Alt+1, click Editor basics | PyCharm (8) and select Enable Preview Tab.

    You can also enable the preview tab in Settings | General | Editor Tabs | Opening Policy.

  2. In the Project tool window, select a file that is not already open in any other tab.

    The name of the file is written in italics to indicate preview mode. Any other file that you select will replace the previous one in the preview tab.

    Start editing the file or double-click the file's tab to exit preview mode and convert the preview tab into a regular tab.

    Editor basics | PyCharm (9)

    Note that when the preview tab is enabled, the Open Files with Single Click option is ignored. Double-click a file to open it in a regular tab.

Hide tabs if there is no more space

  1. Press Control+Alt+S to open the IDE settings and then select Editor | General | Editor Tabs.

  2. Select the Hide tabs if there is no space option. Extra tabs will be placed in the drop-down list (Editor basics | PyCharm (10)) located in the upper right part of the editor.

Display multiple tabs in new UI

When you open more tabs than your screen can fit, you can place them in one or several rows.

  1. Press Control+Alt+S to open the IDE settings and then select Editor | General | Editor Tabs.

  2. In the Show tabs in section, select one of the following options:

    • One row, and if tabs don't fit: place all tabs in one row, and if the tabs do not fit:

      • Scroll the tabs panel: display the scroll bar and scroll the tabs.

      • Squeeze tabs: shrink tabs to fit them on the screen.

    • Multiple rows: place tabs in several rows.

Change the font size in tabs

  1. In the Settings dialog (Control+Alt+S), go to Appearance & Behavior | Appearance.

  2. In the Size field, specify the font size and click OK to save the changes.

    Keep in mind that the font size will change not only for the tabs but for tool windows as well.

Split screen

PyCharm offers various actions that you can invoke from the main or context menu, the editor, or the Project tool window to split the editor screen.

  • In the editor, right-click the desired editor tab and select how you want to split the editor window (Split Right or Split Down). PyCharm creates a split view of the editor and places it according to your selection.

  • As an alternative, from the main menu, select Window | Editor Tabs and the Split and Move Right or Split and Move Down option.

  • You can drag a tab vertically or horizontally in order to split the editor, and drag the tab back to unsplit the screen.

    Editor basics | PyCharm (11)
  • You can open a file in the editor in the right split.

    In the Project tool window, right-click the file and select Open in Right Split from the context menu. PyCharm will open the file in the split on the right of the editor.

    If there are two splits and focus is in the left split, the file will be opened in the existing right split. If the focus is in the right split, the file will be opened in the next right split.

  • You can move files between split screens. Right-click the necessary file tab in the editor and select Move To Opposite Group or Open In Opposite Group from the context menu.

  • You can close all the open tool windows at once and thus enlarge the split screens. Position the caret in an editor tab and press Control+Shift+F12 or just double-click the tab. PyCharm hides all the open tool windows, so all the space is shared by split screens.

  • You can split the editor equally multiple times with the Equalize proportions in nested splits option.

  • To unsplit the screen, from the context menu, select Unsplit or Unsplit All to unsplit all the split frames.

Move the split screen

  1. Place the caret inside the desired split frame.

  2. From the main menu, select Window | Editor Tabs.

  3. From the list of options, select one of the following options:

    • Stretch Editor to Top

    • Stretch Editor to Left

    • Stretch Editor to Bottom

    • Stretch Editor to Right

    You can assign a shortcut to each option and use the keyboard to stretch the split frame.

    To move between the split frames, from the main menu, select Window | Editor Tabs. From the list of options, select Goto Next Splitter Alt Tab or Goto Previous Splitter Alt Shift Tab, respectively.

Quick popups

Description

Action/Access

Good to know

View a quick definition of a symbol (tag, class, method/function, field, and so on).

Control+Shift+I

Displays the symbol's definition in a popup. You can click the Editor basics | PyCharm (12) icon to open the Find tool window with the item's definition and its usages.

View quick documentation for a code element or a file.

Control+Q

Displays documentation in a popup.

You can press Control+Q twice to open the popup in the Documentation tool window. Press the same shortcut to switch back to the popup.

If you want to change the font size of the text displayed in the popup window, click the Editor basics | PyCharm (13) icon and specify the new font size.

For code elements, you can also view external documentation. While in the quick documentation popup, click Editor basics | PyCharm (14) or press Shift+F1.

You can invoke the quick documentation popup while looking for a class Control+N – for any class displayed in the list. To switch focus to the popup, press the same shortcut.

View context information.

Alt+Q

Shows the current method or class declaration when it is not visible.

View a description of the error or warning at the caret.

Control+F1

Click the code analysis marker to see the list of detected errors. Use F2 or Shift+F2 to navigate to the next or previous error.

Copy the tooltip text to the clipboard.

Hold Alt (on Linux, hold Ctrl+Alt) and click on the tooltip.

View all usages of a code element.

Control+Shift+F7

To control the usages highlighting, go to Settings | Editor | Code Editing, and in the Highlight on Caret Movement, select or clear the Highlight usages on element at caret option.

If you turn on Power Save mode (File | Power Save Mode), the usages won't be highlighted.

Font

You can configure and change the font, its size, and font ligatures. The font size change can be applied to one editor tab only or globally.

Configure the font and font ligatures

  1. In the Settings dialog (Control+Alt+S), go to Editor | Font.

  2. Select the desired font from the list, specify its Size and Line height. You can also enable ligatures and configure typography settings.

  3. Click OK to save the changes.

Change font size from the editor

  1. In the Settings dialog (Control+Alt+S), go to Editor | General (Mouse Control section).

  2. Select the Change font size with Ctrl+Mouse Wheel in option.

  3. Return to the editor, press and hold Control, and adjust the font size using the mouse wheel.

Increase or decrease font size in all tabs

  • In the editor, press Alt+Shift+. to increase the font size globally, and Alt+Shift+, to decrease it.

    PyCharm displays a zoom indicator on the bottom of the editor that shows the current font size and the default one, which you can roll back.

  • The zoom indicator is enabled by default. To disable it, open the Settings dialog (Control+Alt+S), go to Advanced Settings, and clear the Show zoom indicator option in the Editor section.

Useful editor configurations

You can use the Settings dialog (Control+Alt+S) to customize the editor's behavior.

Editor basics | PyCharm (15)

Check the following popular configurations:

Configure code formatting

  1. In the Settings dialog (Control+Alt+S), go to Editor | Code Style.

  2. From the list of languages, select the appropriate one, and configure settings for tabs and indents, spaces, wrapping and braces, hard and soft margins, and so on.

Configure color scheme settings for different languages and frameworks

  1. In the Settings dialog (Control+Alt+S), go to Editor | Color Scheme.

  2. Open the Color Scheme node and select the necessary language or framework. You can also select the General option to configure the color scheme settings for general items, such as code, editor, errors and warnings, popups and hints, search results, and so on.

Configure code completion options

  • In the Settings dialog (Control+Alt+S), go to Editor | General | Code Completion. Here you can configure case-sensitive completion, auto-display options, code sorting, and so on.

Configure caret placement

  • In the Settings dialog (Control+Alt+S), go to Editor | General. In the Virtual Space section, configure the caret placement options.

    Select the Allow placement of caret after end of line option to place the caret on the next line in the same position as the end of the previous line. If this option is cleared, the caret on the next line is placed at the end of the actual line.

    Select the Allow placement of caret inside tabs option to help you move the caret up or down inside the file while keeping it in the same position.

Configure the behavior of trailing spaces on save

  • In the Settings dialog (Control+Alt+S), go to Editor | General. In the Other section, configure options for trailing spaces.

    For example, when you save your code, either manually or automatically, and want to preserve trailing spaces on the caret line regardless of what option is selected in the Strip trailing spaces on save list, select the Always keep trailing spaces on caret line option.

Configure the editor appearance options

  • In the Settings dialog (Control+Alt+S), go to Editor | General | Appearance.

    For example, you can configure the IDE to show the hard wrap guide or parameter hints.

Manage the appearance of long lines

  1. In the Settings dialog (Control+Alt+S), go to Editor | General.

  2. In the Soft Wraps section, specify the appropriate options.

    For example, you can specify file types to which you want to apply soft wraps. It might be helpful when you write documentation in markdown files.

Configure smart keys

You can configure the behavior of basic editor actions to differ depending on the language you use.

  • In the Settings dialog (Control+Alt+S), go to Editor | General | Smart keys.

    For example, for Java, SQL or Python, you can select the Jump outside closing bracket/quote with Tab option to enable navigation outside the closing brackets or quotes with Tab when you type your code.

Last modified: 01 August 2023

Close files in the editor Multiple cursors and selection ranges

FAQs

Editor basics | PyCharm? ›

The PyCharm editor is the main part of the IDE that you use to create, read and modify code. The scrollbar shows errors and warnings in the current file. Breadcrumbs help you navigate inside the code in the current file. The gutter shows line numbers and annotations.

Is PyCharm a text editor? ›

PyCharm is a sophisticated text editor. It has a powerful code editor with support for Python and JavaScript. It also has an intelligent code completion and code refactoring system. The integrated debugger allows you to debug your code line by line as you go.

Is PyCharm written in Python? ›

Is PyCharm the best Python IDE? ›

PyCharm. In industries most professional developers use PyCharm and it has been considered the best IDE for python developers. It was developed by the Czech company JetBrains and it's a cross-platform IDE. It gives daily tips to improve your knowledge of how you can use it more efficiently which is a very good feature.

Is PyCharm free or paid? ›

PyCharm is available in two editions: Professional, and Community. The Community edition is an open-source project, and it's free, but it has fewer features. The Professional edition is commercial, and provides an outstanding set of tools and features. For details, see the editions comparison matrix.

Is Notepad ++ a text editor for Python? ›

Notepad++ is a highly functional, free, open-source, editor for MS Windows that can recognize (i.e., highlight syntax for) several different programming languages from Assembly to XML, and many others inbetween, including, of course, Python.

Is Notepad ++ a text editor or IDE? ›

NetBeans IDE and Notepad++ are primarily classified as "Integrated Development Environment" and "Text Editor" tools respectively. Some of the features offered by NetBeans IDE are: Best Support for Latest Java Technologies.

Can I write C++ in PyCharm? ›

1 Answer. Unfortunately PyCharm does not support any C/C++ coding and there are no existing plugins for PyCharm that will support this. With that said, there is an IDE for C and C++ called CLion which is released by JetBrains just like PyCharm.

What is the difference between Python IDE and PyCharm? ›

Python is the programming language used by software developers to create various applications. PyCharm is an Integrated Development Environment (IDE). Python is the language the developer will be writing in, whereas, PyCharm is the platform where they will be writing to create projects.

Why use PyCharm instead of Python? ›

In conclusion, PyCharm is a powerful and popular IDE for programming in Python. It offers many features such as code completion, debugging, and refactoring, which can make development quicker and more efficient. However, whether or not you should use it depends on your specific needs and preferences.

Does Python have a text editor? ›

While Python comes with its own editor, IDLE, you are by no means restricted to using it. Every editor will have its plusses and minusses. When evaluating which one you would use, a few points are important to keep in mind: The operating system you will be using.

Which text editor is used in Python? ›

Several general editors and IDEs support Python development. These include Visual Studio Code, Eclipse with PyDev, Sublime Text, GNU Emacs, Vi/Vim, and Visual Studio with PTVS.

What type of program is PyCharm? ›

PyCharm is a dedicated Python Integrated Development Environment (IDE) providing a wide range of essential tools for Python developers, tightly integrated to create a convenient environment for productive Python, web, and data science development.

What is considered a text editor? ›

A text editor refers to any form of computer program that enables users to create, change, edit, open and view plain text files. They come already installed on most operating systems but their dominant application has evolved from notetaking and creating documents to crafting complex code.

Top Articles
Latest Posts
Article information

Author: Cheryll Lueilwitz

Last Updated: 08/10/2023

Views: 6064

Rating: 4.3 / 5 (74 voted)

Reviews: 89% of readers found this page helpful

Author information

Name: Cheryll Lueilwitz

Birthday: 1997-12-23

Address: 4653 O'Kon Hill, Lake Juanstad, AR 65469

Phone: +494124489301

Job: Marketing Representative

Hobby: Reading, Ice skating, Foraging, BASE jumping, Hiking, Skateboarding, Kayaking

Introduction: My name is Cheryll Lueilwitz, I am a sparkling, clean, super, lucky, joyous, outstanding, lucky person who loves writing and wants to share my knowledge and understanding with you.