rubberduck-vba / Rubberduck

Every programmer needs a rubberduck. COM add-in for the VBA & VB6 IDE (VBE).
https://rubberduckvba.com
GNU General Public License v3.0
1.91k stars 300 forks source link

Blank Space Removal Within Procedures #5377

Open ManuellaJessop opened 4 years ago

ManuellaJessop commented 4 years ago

Justification I'm not sure there's a real justification other than it would be nice to have!!

Description I'd love the option for the indenter to also remove multiple blank lines just leaving 1...given that this is already possible between procedures I would hope it would be simple(ish) to implement?

A more complicated option would be to have a search and replace function that includes the special character ^p as is used in Word to mean new line, so that it would be possible to search for ^p^p and replace with ^p (or anything )...I suspect that this is much more complicated though!

Additional context Add any other context or screenshots about the feature request here.

retailcoder commented 4 years ago

Not sure about the Word-specific part, but I agree this would be a very nice indenter option!

ManuellaJessop commented 4 years ago

Thank you! It’s a fabulous addin – thank you to everyone who works on it!

Greedquest commented 4 years ago

Or even more nice to have; the option to specify where whitespace goes - e.g I normally write my select statements like Matt did once

Select Case level

    Case LogLevel.DebugLevel
        FormatLogLevel = "DEBUG"

    Case LogLevel.ErrorLevel
        FormatLogLevel = "ERROR"

    Case LogLevel.FatalLevel
        FormatLogLevel = "FATAL"

    Case LogLevel.InfoLevel
        FormatLogLevel = "INFO"

    Case LogLevel.TraceLevel
        FormatLogLevel = "TRACE"

    Case LogLevel.WarnLevel
        FormatLogLevel = "WARNING"

End Select

... or sometimes with no newline between Select Case and the first case statement. Similar with if blocks and loops.

An option to

Insert newline before dedent/outdent

...would work for most situations, and of course as well as adding newlines the indenter could remove/coalesce some.

ManuellaJessop commented 4 years ago

Ooh yes please!!!!

TroyB9 commented 4 years ago

To keep this request really simple and quickly achievable, can we just have a single checkbox option that tells the indenter to remove double spacing? [x] remove double spacing ... I personally manually separate code blocks according to my own preference and often spend a lot of time removing extra spacing after code editing and this would save a tremendous amount of time. Thank you! Edit: As mentioned earlier: Essentially ^p^p to ^p.

Vogel612 commented 4 years ago

This is commonly implemented in other formatters as a "Preserve [ ] blank lines" option, which can easily be adapted to each user's formatting preferences (and even be split for inside of procedures and inside of modules)

daFreeMan commented 4 years ago

I'd vote for @Vogel612's suggestion of preserving existing vertical spacing instead of removing extra spacing. That way, each user/team can format to his/her content and be insured that the intender will preserve whatever has been done instead of worrying about having all that vertical space addition/deletion borked up by a simple indention procedure.

Additionally, I would think that it would be much easier to implement preservation of existing spaces than it would be to handle the configuration, storage and implementation of 10 bajillion vertical spacing rules.