Editing code | Qt Creator Documentation
Description: Edit and navigate code and other resources in your projects.

- Qt Creator Documentation
- How to
- Editing code
- Qt Creator 19.0.0

Completion ◦ FakeVim

# Editing code

> How to: Edit code

Write and navigate code in the Edit mode.

## Writing code

The Qt Creator code editor offers code editing services, such as:

- Semantic highlighting

  Qt Creator helps you to write well formatted code by highlighting code elements and blocks. You can use syntax highlighting also for other types of files than C++ or QML.

- Checking code syntax

  Qt Creator checks for errors when you write code and displays inline error and warning messages. Similarly, it checks the data structure of an instance of a JavaScript object notation (JSON) entity. Run static checks on the QML and JavaScript code in your project to find common problems.

- Code completion

  Qt Creator anticipates what you are going to write and completes code and code snippets for elements, properties, and IDs.

- Indenting text or code

  Qt Creator indents text and code according to rules that you specify separately for files that have C++, QML, or Nim (experimental) code and for other text files.

## Navigating code

Split the editor view to work on several files simultaneously and move between files and symbols in the following ways:

- Locate them with the locator.
- Use the views in the sidebar.
- Go to the Edit and Window menu.
- Use keyboard shortcuts.
- Bookmark code.
- Select buttons on the editor toolbar.

### Using tabbed editors

To open files in separate tabs in editors, go to Preferences > Environment > Interface, and then select Use tabbed editors.

To move to the previous or next tab in the Edit mode, go to Window and select Previous Tab (Ctrl+Alt+Right) or Next Tab (Ctrl+Alt+Left).

To pin a tab to the front of the tab bar, right-click the tab and select Pin. Select to unpin the tab.

### Using minimap

To navigate code visually, you can use a minimap, which shows an overview of the file content alongside the editor.

To show the minimap in the editor, go to Preferences > Text Editor > Display, and then select Enable minimap.

## Editor toolbar

The editor toolbar is context sensitive and shows items relevant to the file currently open in the editor.

Editor toolbar when a C++ source file is open

Editor toolbar when a QML UI file is open

Button or Field | Purpose | Read More
--- | --- | ---
| Browse backward or forward through your location history. |
| Shows the currently open file. | Move between files
| Shows the current symbol. | Move to symbols
# | Change the active parse context. | Parse files
| Switch between Windows line endings (CRLF) and Unix line endings (LF). | Select line ending style
| Change the file encoding. | Change text encoding
| View the language server for the current project (such as clangd), restart it, select another one, inspect the communication between Qt Creator and language servers, view server capabilities, and set language server preferences. | Managing language servers
QDS | Open UI files (`.ui.qml`) in Qt Design Studio. | Qt Design Studio documentation
| Preview changes to QML code live in your application. | Preview a QML file on desktop
| Run Clang-Tidy or Clazy to analyze the currently open file. | Analyze code with Clang-Tidy and Clazy
| Jump to a line and column in the current file. The line and column indicator shows information about the current cursor positions, including the length of the selection for selected text. |
| Select commands to automatically indent the current selection and to change the indentation settings. | Specifying tab preferences

### Hiding options

To show or hide the file encoding, line ending, and tab size fields on the editor toolbar, go to Preferences > Text Editor > Display.

## Adding space around toolbar items

To add more space around the toolbar items, go to Preferences > Environment > Interface, and then select Relaxed in the Toolbar style field.

## Resizing views

To resize the editor views and splits, move the cursor to the edge of the view or split. When the cursor changes, drag the edge of the view or split to another position.

If the cursor does not change, go to Preferences > Environment > Interface and select Override cursors for views.

## Copying file information

To open a context menu that has commands for managing open files, right-click the file name or icon on the toolbar (1). It has the same commands as the File menu, as well as commands that copy the path and name of the current file and the number of the line where the cursor is currently located to the clipboard: Copy Full Path, Copy File Name, and Copy Path and Line Number.

## Editing selected lines

In the Edit mode, go to Edit > Advanced to edit lines of text that you select in the editor:

- To duplicate the selected lines, go to Duplicate Selection.
- To format the duplicated lines as a comment, go to Duplicate Selection and Comment.
- To turn selected text into lowercase, go to Lowercase Selection or select Alt+U.
- To turn selected text into uppercase, go to Uppercase Selection or select Alt+Shift+U.
- To sort selected lines alphabetically, go to Sort Selected Lines or select Alt+Shift+S.
- To add a cursor at the next occurrence of selected text for multi-cursor editing, go to Add Next Occurrence to Selection or select Ctrl+D

See also How to: Edit code, How to: Manage language servers, Navigate with locator, Keyboard shortcuts, and Show and hide sidebars.

Completion ◦ FakeVim