coding-style.asciidoc (1093B)
1 C++ Coding Style 2 ================ 3 4 Kakoune is written in C++20, here are the main coding style points: 5 6 * Avoid external dependencies besides posix/stdc++ 7 8 * 4 spaces for indentation, no tabs 9 10 * public interface before private methods/data when defining a class 11 12 * use +override+ keyword for overridden virtual methods 13 14 * opening brackets on their own lines by default, except when declaring 15 an object where the opening bracket follows the equal sign. 16 17 * use alternative logical operator names (and, or, not instead of &&, ||, !) 18 19 ----- 20 int func() 21 { 22 if (condition) 23 { 24 ... 25 } 26 else 27 statement; 28 } 29 30 int array[] = { 31 ... 32 }; 33 ----- 34 35 * End lines with an operator when continuing on the next line 36 37 ---- 38 if (condition1 or 39 condition2) 40 ---- 41 42 * Try to keep under 80 columns, even though this is not a strict limit. 43 44 * CamelCase for types, snake_case for variables/function names 45 46 * prefix fields with m_, static ones with ms_ except for dumb structs 47 (struct with every field public) where these prefixes can be dropped. 48 49 * use const and constexpr liberally