Skip to content

Change operator placement for smart-concat feature #5130

Open
@Greedquest

Description

@Greedquest

Justification
I was reading the python PEP 8 style guide, and noticed something that could apply equally well to VBA code. The guidelines include instruction on whether to insert line breaks before or after a binary operator - you can read some justification there, but I think ultimately the look is really nice, and I believe this is a stylistic guideline that VBA developers should adhere to as well.

The smart concat feature currently places operators at the end of a line, before the line break _ character. I would propose moving them to the beginning of the subsequent line.

Description
Here's what I get at the moment:

Err.Description = "This is a very long sentence " & _
                  "with lots of linebreaks, to " & _
                  "demonstrate the smart-concat " & _
                  "feature"

And here's what I would propose:

Err.Description = "This is a very long sentence " _
                  & "with lots of linebreaks, to " _
                  & "demonstrate the smart-concat " _
                  & "feature"

With the multiline smart-concat (ctrl+enter) I'm in split minds as to the placement of vbNewLine following this change

Err.Description = "Invalid timer function supplied; timer functions must be one of:" & vbNewLine _
                  & " - a TIMERPROC pointer" & vbNewLine _
                  & " - an ITimerProc instance" & vbNewLine _
                  & " - a class name String"

Err.Description = "Invalid timer function supplied; timer functions must be one of:" _
                  & vbNewLine & " - a TIMERPROC pointer" _
                  & vbNewLine & " - an ITimerProc instance" _
                  & vbNewLine & " - a class name String"

I'd probably slightly favour the former (possibly that's just because I'm used to it as the current way of doing things), however I think it's definitely an improvement on having the & operator before the linebreak.

Additional context
Worth noting that this plays nicely with the smart indenter provided the "Ignore operators" setting is unchecked

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementFeature requests, or enhancements to existing features. Ideas. Anything within the project's scope.feature-autocompletefeature-settingsfeature-smart-concatAC issues specific to the "smart concatenation" handleruser-experienceIssue relates to user experience (workflow, flexibility, customisation)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions