mirror of
https://github.com/vim/vim
synced 2025-07-16 01:01:58 +00:00
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
|
||||
@ -230,7 +230,6 @@ For everything else use: >
|
||||
// comment
|
||||
<
|
||||
|
||||
|
||||
INDENTATION *style-indentation*
|
||||
|
||||
We use 4 space to indent the code. If you are using Vim to edit the source,
|
||||
@ -259,7 +258,6 @@ Wrong: >
|
||||
int *ptr;
|
||||
<
|
||||
|
||||
|
||||
BRACES *style-braces*
|
||||
|
||||
All curly braces must be returned onto a new line:
|
||||
@ -288,84 +286,47 @@ OK: >
|
||||
while (cond)
|
||||
{
|
||||
cmd;
|
||||
cmd;
|
||||
}
|
||||
<
|
||||
Wrong: >
|
||||
while (cond) {
|
||||
cmd;
|
||||
cmd;
|
||||
}
|
||||
<
|
||||
When a block has one line, including comments, the braces can be left out.
|
||||
OK: >
|
||||
if (cond)
|
||||
do
|
||||
{
|
||||
cmd;
|
||||
else
|
||||
cmd;
|
||||
} while (cond);
|
||||
<
|
||||
or >
|
||||
do
|
||||
{
|
||||
cmd;
|
||||
cmd;
|
||||
}
|
||||
while (cond);
|
||||
<
|
||||
Wrong: >
|
||||
if (cond)
|
||||
/*
|
||||
* comment
|
||||
*/
|
||||
do {
|
||||
cmd;
|
||||
else
|
||||
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*
|
||||
|
||||
Use descriptive types. You can find a list of them in the src/structs.h file
|
||||
and probably in a typedef in the file you are working on.
|
||||
|
||||
Use descriptive types. These are defined in src/vim.h, src/structs.h etc.
|
||||
Note that all custom types are postfixed with "_T"
|
||||
|
||||
OK: >
|
||||
int is_valid_line_number(linenr_T lnum);
|
||||
Example: >
|
||||
linenr_T
|
||||
buf_T
|
||||
pos_T
|
||||
<
|
||||
Wrong: >
|
||||
int is_valid_line_number(unsigned long lnum);
|
||||
<
|
||||
|
||||
|
||||
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.
|
||||
|
||||
Wrong: var=a*5;
|
||||
OK: var = a * 5;
|
||||
Wrong: var=a*5;
|
||||
|
||||
Use empty lines to group similar actions together.
|
||||
|
||||
@ -412,7 +373,6 @@ Wrong: >
|
||||
while (buf != NULL && !got_int)
|
||||
<
|
||||
|
||||
|
||||
FUNCTIONS *style-functions*
|
||||
|
||||
Use function declarations with the return type on a separate indented line.
|
||||
|
Reference in New Issue
Block a user