How to clang-format LibreOffice code-base only for selected code piece(s) - VSCode
According to https://wiki.documentfoundation.org/Development/clang-format:
Then, to reformat the whole file:
We can reformat a file easily. But what if we want to do clang-format only for a specific code-piece(s) (e.g. a function, class, if-else …) instead?
On VSCode
(Linux):
File
>Preferences
>Settings
.- Search for
clang-format
. - in
C_Cpp: Clang_format_path
section, set the path of the clang-format executable as/opt/lo/bin/clang-format
.
For example, let’s only select the if statement here:
Then right click
on the selection and select Format Selection
:
Finally, formatting only for if statement should work: