DevEco Studio allows you to develop apps/atomic services in multiple programming languages, including ArkTS, JS, and C/C++. When writing code, make most of the following editor tips to improve your work productivity.
The editor displays code in different colors by keyword, operator, string, class, identifier, comment, and more. To customize the color scheme, choose File > Settings on the menu bar (on macOS, choose DevEco Studio > Preferences/Settings) and then choose Editor > Color Scheme from the left pane. The color scheme configured under Language Defaults applies to projects of all programming languages. To set the color scheme specific to a programming language, select the language from the left pane, and deselect Inherit values from on the right pane.

You can move about your code with ease. To jump to the definition of a symbol, such as a class, method, parameter, or variable, just click it while pressing and holding Ctrl (Command on macOS). To find references to a symbol, simply click the symbol. If there is only one reference, you'll be redirected straightaway to it. If there is a list of references, you can choose which one you want to navigate to.

If your code file (such as d.ts) contains a declaration of or a reference to a C/C++ function, you can navigate to that function easily. Just right-click a symbol name and choose Go To > Implementation(s) from the shortcut menu (or press Ctrl+Alt+B; press Command+Option+B on macOS).

The editor can format your code to make it easier to read according to the preset code style settings. You can also apply custom code style settings to the specified files as follows: Under File > Settings > Editor > Code Style (DevEco Studio > Preferences/Settings > Editor > Code Style on macOS), select a file type, for example, ArkTS, and customize the code style settings.

You can use shortcut keys Ctrl+Alt+L (Option+Command+L on macOS) to quickly format selected code snippets.
To exclude certain code snippets from the automatic formatting scope, perform the following:


If the project already has a code-linter.json5 file configured, right-click the file and select Apply CodeLinter Style Rules. The code formatting rules will then be consistent with the rules defined in the configured code-linter.json5 file. For details about how to configure the code-linter.json5 file, see Configuring Code Check Rules.

You can collapse or fold blocks of code while you are not working on them. To quickly collapse or expand a block of code, just click the collapse or expand button on the left sidebar of the editor. Better yet, you can right-click a block of code and choose how you want to collapse it, including Collapse, Collapse Recursively, and Collapse All.

You can press Ctrl+/ (Command+/ on macOS) to quickly comment out a selected block of code. Press Ctrl+/ (Command+/ on macOS) again to uncomment.

Press Alt+7 or Ctrl+F12 (Command+7 on macOS) to open the code structure tree, where you can easily locate code elements, such as global variables, functions, class member variables, and methods, and quickly navigate to the corresponding code in the editor.

With the Find Usages feature, you can search for the references of a code element, such as a variable, function, or class, throughout the codebase. This is useful for subsequent code refactoring and can greatly improve development efficiency.
Usage: Right-click the code element for which you want to find usage, and choose Find Usages from the shortcut menu or press Alt+F7 (Option+F7 for macOS). Click the
icon to view where the variable is assigned, and click the
icon to see where the variable is referenced.

An easy-to-use code comment generator is in place to help you quickly create comments for your code. In front of the code block of a function definition, enter /** and press Enter to insert a commented line.
In C++ files you can also enter //! and press Enter to quickly generate comments.

You can navigate through code by navigating between symbols, classes, or files. You can examine the call and type hierarchies and explore the structure of source files. Just press Shift twice to open the code search page, and enter the keywords in the search box. The search results are displayed in the lower part of the page in real time. Click a search result to go to where it is located.

Since DevEco Studio 6.0.2 Beta1, the Show in API Reference feature supports shortcut key access.
The editor provides instant access to reference documents for ArkTS/JS APIs or components, without the hassle of navigating to a specified web page.
Hover the mouse over an API or a component to display a popup with information about its parameters and other details across different API versions. To obtain the complete API reference document, click Show in API Reference in the lower-right corner of the popup, or right-click an API or a component and choose Show in API Reference from the shortcut menu (keyboard shortcut: Alt+A on Windows; Option+A on macOS).
The API reference documents integrated in DevEco Studio may not be up to date. To obtain the latest version, see HarmonyOS API References.

In the popup, the following information is available:

The editor's Optimize Imports feature helps you remove unused imports and merge or sort imports based on preset rules. Select a file or directory and press Ctrl+Alt+O (Control+Option+O on macOS), or choose Code > Optimize Imports from the menu bar.

To modify the optimization settings, choose File > Settings (DevEco Studio > Preferences/Settings on macOS) > Editor > Code Style and select a programming language (ArkTS is used as an example here). On the Imports tab page, set the fields based on your needs.

Starting from version 5.1.0 Release, DevEco Studio provides the capability to query and compare behavioral changes in the ArkTS APIs used by the current project since a specified SDK version, along with adaptation guide links to facilitate code modification.
Since DevEco Studio 5.1.1 Release, this feature supports C APIs and provides the cross-version change query capability.
Since DevEco Studio 6.0.2 Beta1, a scan progress indicator has been added. The specific locations of changed APIs in your code can be viewed in Code Location.
Since DevEco Studio 6.1.0 Beta2, the API change query feature has been integrated with CodeGenie's quick Q&A. CodeGenie provides modification suggestions for incompatible APIs based on your code files and change documents, and supports API change type filtering.
// API definition
interface ProgressInterface {
<Type extends keyof ProgressStyleMap>(options: ProgressOptions<Type>): ProgressAttribute<Type>; // Change query is not supported for APIs with extends or keyof keywords.
}
// API calling
Progress({ value: 10, type: ProgressType.Capsule })
.style({content:'Install'}) template <class _Rep, class _Period> cv_status condition_variable::wait_for(unique_lock<mutex>& __lk,const chrono::duration<_Rep, _Period>& __d) // Querying for changes to API functions implemented in C++ is not supported.
// Example: via function pointers int (*sigptr)(int, const struct sigaction *__restrict, struct sigaction *__restrict) = &sigaction; sigptr(NULL,NULL); // Example: via callbacks callback(sigaction); // Example: via custom macros #define MySig sigaction MySig(NULL,NULL);
Perform the following steps if DevEco Studio 6.0.0 Release or later is used:
The API change query feature uses the selected starting version as a baseline to check for behavioral changes in the APIs used in the current project. For example, when you select SDK versions from 5.0.0(12) Release to 6.0.0(20) Release, the query covers changes introduced between 5.0.1(13) Beta3 and 6.0.0(20) Release, compared with the baseline of 5.0.0(12) Release.

to mark the item as fixed. Use the following options to search or filter the API change scan results, and export the data:
After CodeGenie is opened via Quick Ask, only the HarmonyOS Ask agent is available for quick Q&A.
Perform the following steps if a version earlier than DevEco Studio 6.0.0 Release is used:
The API change query feature uses the selected starting version as a baseline to check for behavioral changes in the APIs used in the current project. For example, when you select SDK versions from 5.0.0(12) Release to 6.0.0(20) Release, the query covers changes introduced between 5.0.1(13) Beta3 and 6.0.0(20) Release, compared with the baseline of 5.0.0(12) Release.



In the editor you can quickly navigate to the parent or child class of the selected interface, class, method, and property. You can navigate to its parent or child interface or class by clicking the corresponding gutter icons on the left of the code editing area. If there are multiple inheritance relationships, simply select the desired interface or class from the list presented in the popup window.
Implemented: navigates to the corresponding implementation classes or sub-interfaces and their respective properties and methods.
Implementing: navigates to the corresponding parent interface or its properties and methods.
Overridden: navigates to the corresponding child class or the properties/methods of the child class.
Overriding: navigates to the corresponding parent class or the properties/methods of the parent class.
The preceding features under Gutter Icons are enabled by default. To enable or disable these features, choose File > Settings (DevEco Studio > Preferences/Settings on macOS) > Editor > General > Gutter Icons from the menu bar, and select or deselect the check boxes as needed.

In the editor you can examine the hierarchy of interfaces and classes. Select the desired class or interface name or hover the cursor over it, then press Ctrl+H (Control+H on macOS) or choose Type Hierarchy on the Navigate tab page. In the displayed Hierarchy window, view the inheritance hierarchy of the class or interface.

The table below describes the icons in the Hierarchy window.
Icon | Description |
|---|---|
| Displays the parent and child classes of the selected class. This feature does not support the query of inheritance relationships. |
| Displays the parent class of the selected class or interface. |
| Displays the child class of the selected class or interface. |
| Sorts all sibling elements in the inheritance structure tree alphabetically. |
| Refreshes the inheritance structure for all classes or interfaces. |
| Enables you to navigate to the code location of a class or interface in the editor with a single click of the class or interface name in the structure tree. By default, a double-click is needed for the navigation. |
| Expands or collapses the inheritance structure. |
| Locks the current Hierarchy window to stay on top of the editor window. |
| Exports the inheritance structure of the selected class or interface to a text file. |
| Closes the window. |
Since 26.0.0, the editor allows you to view the binding relationships of state variables. Right-click the decorator or variable attribute definition and choose Show State Variable Binding Relationship from the shortcut menu. In the State Variables dialog box, view the binding relationships of ArkUI component state variables.
The following types of state variable binding relationships are currently supported:

The table below describes the icons in the State Variables window.
Icon | Description |
|---|---|
| Refreshes all state variable relationships. |
| Jumps to the previous node. |
| Jumps to the next node. |
| Expands or collapses state variable relationships. |
Since DevEco Studio 6.0.0 Beta2, enabling inlay hints during editing provides code description information such as parameter names and types, improving code readability.

Go to File > Settings (DevEco Studio > Preferences/Settings on macOS) > Editor > Inlay Hints, configure and check the variable name, property, parameter, and return value types you want to display, and click OK for the settings to take effect.

Copy reference is supported since DevEco Studio 6.0.0 Beta2. On the editing page, select code lines or names of classes, methods, parameters, and variables, right-click and select Copy / Paste Special > Copy Reference. This will automatically copy the address of the definition. Once copied, the address can be searched in the search box that pops up by a double-press on Shift, helping you quickly locate the definition of the API.
