Indentation of return type in function definition

27 views
Skip to first unread message

Rene Kita

unread,
Dec 25, 2020, 8:09:27 AM12/25/20
to vim...@googlegroups.com
To be clear: I don't want to start a discussion/war about coding style
here! I'm just curios.

In vim's source code, why is the line with the return type and modifiers
of a function indented? Is there a rational? Historical reason? Or is it
just that Bram likes it this way?

Example:
int
vim_main2(void)
{

I know for reasons to put the int on its own line, just wondering about
the indent.

Bram Moolenaar

unread,
Dec 25, 2020, 11:42:07 AM12/25/20
to vim...@googlegroups.com, Rene Kita
This makes it easier to spot the function name. The type can be long,
and then there's usually a comment above it, the "indent gap" makes the
name stand out.

I have been thinking of aligning the return type with the paren before
the first argument:

int
vim_main2(void)
{

But I don't think it is an improvement.


--
How To Keep A Healthy Level Of Insanity:
6. In the memo field of all your checks, write "for sexual favors".

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
Reply all
Reply to author
Forward
0 new messages