DEV Community

ZHZL-m
ZHZL-m

Posted on

【Journey of HarmonyOS Next】DevEco Studio User Guide (8)

Image description

1 -> code highlighting

You can highlight code keywords, operators, strings, classes, identifiers, comments, etc., and you can open the File > Settings (DevEco Studio > Preferences for macOS) panel and > Color Scheme in EditorCustomize the highlight color for each field. By default, you can set the various highlighting schemes in your source code in Language Defaults, which will take effect for all languages; If you need to customize the source code highlighting scheme for a specific language, you can select the corresponding language in the left sidebar, and then cancel the "Inherit values from" option and set the corresponding color.

Image description

2 -> code jump

In the editor, you can hold down the Ctrl key (Command key for macOS) and click the name of the class, method, parameter, variable, etc. referenced in the code to automatically jump to the definition. If you click on the name of a class, variable, etc., in the definition area, you can jump directly to the reference location when there is only one reference. If there are multiple references, you can select the reference location you want to view in the pop-up window.

Image description

3 -> Cross-language jumping

DevEco Studio supports cross-language jumps to the corresponding C/C++ functions in files that declare or reference native interfaces (such as d.ts), thus improving the development efficiency of mixed language development. You can right-click the interface name and select Go To > Implementation(s) from the pop-up menu (or use the shortcut key Ctrl+Alt+B, or Command+Option+B for macOS) to implement cross-language jumping.

Image description

4-> Code formatting

The code formatting function can help us quickly adjust and standardize the code formatting, and improve the beauty and readability of the code. By default, DevEco Studio has preset code formatting specifications, and you can also set the formatting specifications for each file individually as follows: File > Settings > Editor > Code Style (DevEco Studio > Preferences > Editor > Code for macOS.) Style), select the file type that needs to be customized, such as ArkTS, and then customize the formatting specification.

Image description

When using the code formatting function, you can use the shortcut key Ctrl + Alt + L (Option+Command + L for macOS) to quickly format the code of the selected range.

If you do not need to automatically format some code snippets during formatting, you can set them as follows:

  1. In File > Settings >Editor > Code Styl (DevEco Studio > Preferences > Editor > Code Style for macOS), click "Formatter" and select "Turn formatter on/off with". markers in code comments”。

Image description

  1. Add "//@formatter:off" before the block of code that does not need to be formatted, and add "//@formatter:on" to the end of the block, which means that the block of code for the range does not need to be formatted.

Image description

  1. If the code-linter.json5 file has been configured for the project, right-click the code-linter.json5 file and select Apply CodeLinter Style Rules, the code formatting rules will be consistent with the relevant rules in the code-linter.json5 file.

Image description

5-> code folding

You can click the collapse and expand button on the sidebar on the left side of the editor to fold and expand the code block, and right-click the selected code block to select the folding method, including folding, recursive folding, and all folding.

Image description

6-> Code Quick Comments

Supports quick comments on selected code blocks, using the shortcut key Ctrl+/ (Command+/ for macOS) for quick comments. For a code block that has already been commented, use the shortcut Ctrl+/ (Command+/ for macOS) again to uncomment it.

Image description

Top comments (0)