[cfe-dev] clang-format option for formatting closing brace of initializer lists

Julian Andres Klode via cfe-dev cfe-dev at lists.llvm.org
Sat Sep 9 09:47:18 PDT 2017


Hi,

is there a way to configure clang-format to break line before the end of an
initializer list?

So, not do this:

   static const char *WaitingTasks[][6] = {
       {"systemd-networkd.service", "/lib/systemd/systemd-networkd-wait-online", "-q", "--timeout=30", nullptr},
       {"NetworkManager.service", "nm-online", "-q", "--timeout", "30", nullptr}};

but rather this:

   static const char *WaitingTasks[][6] = {
       {"systemd-networkd.service", "/lib/systemd/systemd-networkd-wait-online", "-q", "--timeout=30", nullptr},
       {"NetworkManager.service", "nm-online", "-q", "--timeout", "30", nullptr}
   };

(possibly with a trailing comma on the nm-online line for consistency).

This style looks much cleaner to me. Somewhat unrelated, it's also the
style gofmt uses.

(Please To/CC on replies, not subscribed)
-- 
Debian Developer - deb.li/jak | jak-linux.org - free software dev
                  |  Ubuntu Core Developer |
When replying, only quote what is necessary, and write each reply
directly below the part(s) it pertains to ('inline').  Thank you.



More information about the cfe-dev mailing list