runtime(doc): Tweak documentation style in develop.txt
closes: #17252 Signed-off-by: Hirohito Higashi <h.east.727@gmail.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
committed by
Christian Brabandt
parent
ba0062b0c7
commit
55f9e2bef9
@ -1,4 +1,4 @@
|
|||||||
*develop.txt* For Vim version 9.1. Last change: 2025 Apr 18
|
*develop.txt* For Vim version 9.1. Last change: 2025 May 05
|
||||||
|
|
||||||
|
|
||||||
VIM REFERENCE MANUAL by Bram Moolenaar
|
VIM REFERENCE MANUAL by Bram Moolenaar
|
||||||
@ -230,7 +230,6 @@ For everything else use: >
|
|||||||
// comment
|
// comment
|
||||||
<
|
<
|
||||||
|
|
||||||
|
|
||||||
INDENTATION *style-indentation*
|
INDENTATION *style-indentation*
|
||||||
|
|
||||||
We use 4 space to indent the code. If you are using Vim to edit the source,
|
We use 4 space to indent the code. If you are using Vim to edit the source,
|
||||||
@ -259,7 +258,6 @@ Wrong: >
|
|||||||
int *ptr;
|
int *ptr;
|
||||||
<
|
<
|
||||||
|
|
||||||
|
|
||||||
BRACES *style-braces*
|
BRACES *style-braces*
|
||||||
|
|
||||||
All curly braces must be returned onto a new line:
|
All curly braces must be returned onto a new line:
|
||||||
@ -288,84 +286,47 @@ OK: >
|
|||||||
while (cond)
|
while (cond)
|
||||||
{
|
{
|
||||||
cmd;
|
cmd;
|
||||||
|
cmd;
|
||||||
}
|
}
|
||||||
<
|
<
|
||||||
Wrong: >
|
Wrong: >
|
||||||
while (cond) {
|
while (cond) {
|
||||||
cmd;
|
cmd;
|
||||||
|
cmd;
|
||||||
}
|
}
|
||||||
<
|
<
|
||||||
When a block has one line, including comments, the braces can be left out.
|
|
||||||
OK: >
|
OK: >
|
||||||
if (cond)
|
do
|
||||||
|
{
|
||||||
cmd;
|
cmd;
|
||||||
else
|
|
||||||
cmd;
|
cmd;
|
||||||
|
} while (cond);
|
||||||
|
<
|
||||||
|
or >
|
||||||
|
do
|
||||||
|
{
|
||||||
|
cmd;
|
||||||
|
cmd;
|
||||||
|
}
|
||||||
|
while (cond);
|
||||||
<
|
<
|
||||||
Wrong: >
|
Wrong: >
|
||||||
if (cond)
|
do {
|
||||||
/*
|
|
||||||
* comment
|
|
||||||
*/
|
|
||||||
cmd;
|
cmd;
|
||||||
else
|
|
||||||
cmd;
|
cmd;
|
||||||
|
} while (cond);
|
||||||
<
|
<
|
||||||
When an `if`/`else` has braces on one block, the other should have it too.
|
|
||||||
OK: >
|
|
||||||
if (cond)
|
|
||||||
{
|
|
||||||
cmd;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
cmd;
|
|
||||||
cmd;
|
|
||||||
}
|
|
||||||
<
|
|
||||||
Wrong: >
|
|
||||||
if (cond)
|
|
||||||
cmd;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
cmd;
|
|
||||||
cmd;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (cond)
|
|
||||||
{
|
|
||||||
cmd;
|
|
||||||
cmd;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
cmd;
|
|
||||||
<
|
|
||||||
OK: >
|
|
||||||
while (cond)
|
|
||||||
cmd;
|
|
||||||
<
|
|
||||||
Wrong:
|
|
||||||
>
|
|
||||||
while (cond)
|
|
||||||
if (cond)
|
|
||||||
cmd;
|
|
||||||
<
|
|
||||||
|
|
||||||
|
|
||||||
TYPES *style-types*
|
TYPES *style-types*
|
||||||
|
|
||||||
Use descriptive types. You can find a list of them in the src/structs.h file
|
Use descriptive types. These are defined in src/vim.h, src/structs.h etc.
|
||||||
and probably in a typedef in the file you are working on.
|
|
||||||
|
|
||||||
Note that all custom types are postfixed with "_T"
|
Note that all custom types are postfixed with "_T"
|
||||||
|
|
||||||
OK: >
|
Example: >
|
||||||
int is_valid_line_number(linenr_T lnum);
|
linenr_T
|
||||||
|
buf_T
|
||||||
|
pos_T
|
||||||
<
|
<
|
||||||
Wrong: >
|
|
||||||
int is_valid_line_number(unsigned long lnum);
|
|
||||||
<
|
|
||||||
|
|
||||||
|
|
||||||
SPACES AND PUNCTUATION *style-spaces*
|
SPACES AND PUNCTUATION *style-spaces*
|
||||||
|
|
||||||
@ -386,8 +347,8 @@ Wrong: func(arg1,arg2); for (i = 0;i < 2;++i)
|
|||||||
|
|
||||||
Use a space before and after '=', '+', '/', etc.
|
Use a space before and after '=', '+', '/', etc.
|
||||||
|
|
||||||
Wrong: var=a*5;
|
|
||||||
OK: var = a * 5;
|
OK: var = a * 5;
|
||||||
|
Wrong: var=a*5;
|
||||||
|
|
||||||
Use empty lines to group similar actions together.
|
Use empty lines to group similar actions together.
|
||||||
|
|
||||||
@ -412,7 +373,6 @@ Wrong: >
|
|||||||
while (buf != NULL && !got_int)
|
while (buf != NULL && !got_int)
|
||||||
<
|
<
|
||||||
|
|
||||||
|
|
||||||
FUNCTIONS *style-functions*
|
FUNCTIONS *style-functions*
|
||||||
|
|
||||||
Use function declarations with the return type on a separate indented line.
|
Use function declarations with the return type on a separate indented line.
|
||||||
|
|||||||
Reference in New Issue
Block a user