Skip to content

Option for whitespace surrounding parenthesis/brackets? #1084

Description

@gert-vercleyen

Would it be possible to add an option that controls the whitespace surrounding (nested) brackets?
I'm one of the few people that think the following

f( g( h( a[ 1 ] ), b ) )

is more readable than

f(g(h(a[1]), b))

The above example is a bit extreme but even just h( a[ 1 ], b ) looks nicer to me than h(a[1], b)

I assume whitespace lovers don't really agree on whether f( g( x ) ) is better than f( g(x) ) (i.e. extra whitespace after every opening and before every closing bracket vs only for nested brackets) so I would propose to have two options

  1. extra whitespace only for nested expressions. The inner most brackets of any subexpression have regular spacing. f(g(h(a[1], b), k(x))) would become f( g( h( a[1], b ), k(x) ) )
  2. extra whitespace after every opening and before every closing bracket f(g(h(a[1], b), k(x))) would become f( g( h( a[ 1 ], b ), k( x ) ) )

I'm sorry if this is too much of a niche request and I hope I don't start a flamewar here (a bit hard to avoid though when posting on the subject of code style...)

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Priority 2 — see contributing docsgood first issueGood for newcomers. Do NOT use LLMs!

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions