runtime(doc): Tweak documentation style in develop.txt
Commit:
https://github.com/vim/vim/commit/55f9e2bef927ec30999fd926f1539771a25c7a26
Author: Hirohito Higashi <[email protected]>
Date: Mon May 5 20:19:09 2025 +0200
runtime(doc): Tweak documentation style in develop.txt
closes: https://github.com/vim/vim/issues/17252
Signed-off-by: Hirohito Higashi <[email protected]>
Signed-off-by: Christian Brabandt <[email protected]>
diff --git a/runtime/doc/develop.txt b/runtime/doc/develop.txt
index 18e2caec7..621e7f668 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 @@ them:
- 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 @@ For everything else use: >
// 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 @@ you don't need to do anything due to the |modeline|.
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,114 +258,76 @@ Wrong: >
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)
- cmd;
- else
- cmd;
-<
-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
+or >
+ do
{
cmd;
cmd;
}
+ while (cond);
<
Wrong: >
- if (cond)
- cmd;
- else
- {
- cmd;
- cmd;
- }
-
- if (cond)
- {
- cmd;
- cmd;
- }
- else
+ do {
cmd;
-<
-OK: >
- while (cond)
cmd;
+ } while (cond);
<
-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);
-<
-Wrong: >
- int is_valid_line_number(unsigned long lnum);
+Example: >
+ linenr_T
+ buf_T
+ pos_T
<
-
SPACES AND PUNCTUATION *style-spaces*
No space between a function name and the bracket:
@@ -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.
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion visit
https://groups.google.com/d/msgid/vim_dev/E1uC0Zo-009uxP-6a%40256bit.org.