You can use the experimental Beautifier plugin to format your source code by using the following external tools:
The Beautifier plugin parses the source code into component structures, such as assignment statements, if blocks, loops, and so on, and formats them as specified in the Beautifier options. You can use a predefined style or define your own style.
To use the Beautifier plugin:
You might have to build the tools from sources for some platforms.
This setting is applied only when automatically beautifying files on save. To restrict the MIME types when selecting the menu item to format the currently open file, specify this option in the tool-specific tab.
选择
File
to load the style configuration from the
.clang-format
or
_clang-format
file located in the same directory as the source file or in one of its parent directories.
To specify a fallback style to use if the style configuration file is not available, use the Fallback style combo box. Select 默认 to use the default style. Select None to skip formatting.
Define code formatting in the Add Configuration dialog. It provides syntax highlighting, auto-completion, and context-sensitive help. For these features, you must have the tool installed.
You can create keyboard shortcuts for the functions.
除了
Format Current File
command, ClangFormat and Uncrustify provide additional commands. ClangFormat provides the
Format at Cursor
command. If you select it when no text is selected, the syntactic entity under the cursor is formatted. The
Disable Formatting for Selected Text
command wraps selected lines within
// clang-format off
and
// clang-format on
. Uncrustify provides the
Format Selected Text
command. If you select it when no text is selected, the whole file is formatted by default. To disable this behavior, deselect the
Format entire file if no text was selected
check box.