Open r-plus opened 4 years ago
@r-plus You can use --disable blankLinesAtStartOfScope
to disable the rule that does this.
@nicklockwood thanks for your response.
sorry, my sample is not good. I have mixed code that have space having blank line and no-space blank line. In this case, indent
rule will remove all of the spaces from blank lines.
before format code.
class A {
....
....var a: String?
[empty-line]
....var b: String?
....
}
after the format by $ swiftformat --rules indent --swiftversion 5.1 test.swift
class A {
[empty-line]
....var a: String?
[empty-line]
....var b: String?
[empty-line]
}
I'm won't format about blank lines in this case.
NOTE: swiftformat version 0.42.0
@r-plus you can add the --trimwhitespace nonblank-lines
option if you don't want the whitespace in empty lines to be trimmed.
@nicklockwood with that rule and option by following command
$ swiftformat --rules indent --rules trailingSpace --trimwhitespace nonblank-lines --swiftversion 5.1 test.swift
file will be formatted to
class A {
....
....var a: String?
.... <- changed
....var b: String?
....
}
I won't format about blank lines. So i wanting ignore able option for indent rule for blank lines. How about?
Hmm, this is a pretty obscure use-case. Why do you want the inconsistent whitespace in blank lines to be preserved - is it just to avoid noise in the commit?
yes, i'm thinking changes of blank lines are not meaningful change for code readability.
same problem
@nicklockwood Hi, I won't remove white spaces of blank lines by
indent
rule. What do you think of--blank-lines
option? (e.g.remove
(default) andignore
)