guides:programstyle:whitespace
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
guides:programstyle:whitespace [2020/08/04 17:16] – [Consistently use a single style for brace placement.] wikiadmin | guides:programstyle:whitespace [2024/07/25 15:01] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 26: | Line 26: | ||
* **vi** | * **vi** | ||
* In vi, add //set expandtab// to your .vi, .exrc, vimrc or other | * In vi, add //set expandtab// to your .vi, .exrc, vimrc or other | ||
+ | * **nano** | ||
+ | * In nano, add //set tabstospaces// | ||
+ | * You can also set the size of the indentation with //set tabsize 4// (or whatever size you wish). | ||
+ | |||
Line 209: | Line 213: | ||
==== Place spaces between operators in statements. ==== | ==== Place spaces between operators in statements. ==== | ||
- | ==== Do not exceed 80 characters | + | |
+ | Proper spacing in statements, especially mathematical calculations make it easier to read these statements. | ||
+ | |||
+ | Unacceptable example: | ||
+ | <code c++> | ||
+ | for(i=0; | ||
+ | ... | ||
+ | } | ||
+ | |||
+ | x = r*cos(theta)*sin(phi); | ||
+ | |||
+ | r1 = (-b+sqrt(4*a*c))/ | ||
+ | </ | ||
+ | |||
+ | Acceptable example: | ||
+ | <code c++> | ||
+ | for(i = 0; i < 20; i++) { | ||
+ | ... | ||
+ | } | ||
+ | |||
+ | x = r * cos(theta) * sin(phi); | ||
+ | |||
+ | r1 = (-b + sqrt(4*a*c)) / (2*a); | ||
+ | </ |
guides/programstyle/whitespace.1596561398.txt.gz · Last modified: 2024/07/25 15:01 (external edit)