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>
diff --git a/runtime/doc/develop.txt b/runtime/doc/develop.txt
index 18e2cae..621e7f6 100644
--- a/runtime/doc/develop.txt
+++ b/runtime/doc/develop.txt
@@ -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
@@ -215,7 +215,7 @@
- flexible array members: Not supported by HP-UX C compiler (John Marriott)
-COMMENTS *style-comments*
+COMMENTS *style-comments*
Try to avoid putting multiline comments inside a function body: if the
function is so complex that you need to separately comment parts of it, you
@@ -230,8 +230,7 @@
// comment
<
-
-INDENTATION *style-indentation*
+INDENTATION *style-indentation*
We use 4 space to indent the code. If you are using Vim to edit the source,
you don't need to do anything due to the |modeline|.
@@ -239,7 +238,7 @@
For other editors an `.editorconfig` is provided at the root of the repo.
-DECLARATIONS *style-declarations*
+DECLARATIONS *style-declarations*
Declare, when possible, `for` loop variables in the guard:
OK: >
@@ -259,113 +258,75 @@
int *ptr;
<
-
-BRACES *style-braces*
+BRACES *style-braces*
All curly braces must be returned onto a new line:
OK: >
if (cond)
{
- cmd;
- cmd;
+ cmd;
+ cmd;
}
else
{
- cmd;
- cmd;
+ cmd;
+ cmd;
}
<
Wrong: >
if (cond) {
- cmd;
- cmd;
+ cmd;
+ cmd;
} else {
- cmd;
- cmd;
+ cmd;
+ cmd;
}
<
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 @@
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 @@
while (buf != NULL && !got_int)
<
-
FUNCTIONS *style-functions*
Use function declarations with the return type on a separate indented line.