GNOME Bugzilla – Bug 775521
Automatically Reformat/Reindent Entire File
Last modified: 2017-10-16 08:51:43 UTC
Unfortunately, Gnome Builder does not let you reformat source code automatically to meet the requirements of your code style. In IntelliJ IDEA you can automatically reformat an entire file by pressing CTRL+ALT+L. As simple as that. This is not possible with Gnome Builder (3.22.2). Let's take a badly formatted .html file for example ```html <!DOCTYPE html> <html> <head> <meta charset="utf-8"/> <meta name="robots" content="noarchive"/> </head> </html> ``` The only way seems to be to 1.) select line by line, and then 2.) press CTRL+ALT+l in each line. But I may be wrong. The Menu > Editor Shortcuts page describes the previously mentioned shortcut as "Reindent line", whatever this means. Could be everything or nothing. But even this shortcut does not work, Pressing CTRL+ALT+l on a selected line does nothing at all. Even if you select all the code in the selected line, it simply does not work. Basic features like automatic code indentation are missing. Frustrating!
There's a work in progress here: https://git.gnome.org/browse/gnome-builder/?h=wip%2Fslaf%2Fbeautifier
Currently it only support Uncrustify, but clang-format and probably other beautifiers are coming soon. After some more tests, i'll probably add a generic pattern command line format so that you can easily add your own command launcher, thing not possible with clang-format that want a .clang-format config file in the working dir or one of its parent.
We also support this using language formatters (if present). * Ctrl+f in emacs * gq in vim It looks like we're missing something for default mode. I think rust is the only language providing an IdeFormatter right now though.