nicklockwood / SwiftFormat

A command-line tool and Xcode Extension for formatting Swift code
MIT License
7.63k stars 623 forks source link

How I can setup indentation for empty lines? #1664

Open DanDolog opened 3 months ago

DanDolog commented 3 months ago

Hello! I've encountered a problem. I can’t find information anywhere on how to configure the formatting of empty lines. Do I understand correctly that now in SwiftFormat you can either clear all spaces in empty lines or not format them at all?

I have these settings--indent tab, --tabwidth 4,--trimwhitespace nonblank-lines and SwiftFormat simply ignores this nightmare:

Screenshot 2024-04-01 at 16 23 41

Expected result (Ctrl+I in Xcode):

Screenshot 2024-04-01 at 16 32 30

What do you think and what can you advise in this case? Thanx!

nicklockwood commented 3 months ago

I think this isn't supported at the moment - as you say the options are either to truncate blank lines or leave them alone. I'll consider this a feature request.

DanDolog commented 3 months ago

Thank you very much, I'll be waiting! I think this is a relatively popular problem since many people have spaces and tabs highlighted. And also adding spaces on empty lines is the default behavior of Xcode.

James-chok commented 1 week ago

I've encountered same problem. Please consider this feature. Thank you so much!