Many of the options include the Force
value option:
Add or remove space between nested parens
sp_paren_paren
{Ignore
,Add
,Remove
,Force
}
What does it mean? How is it different than Add
?
Many of the options include the Force
value option:
Add or remove space between nested parens
sp_paren_paren
{Ignore
,Add
,Remove
,Force
}
What does it mean? How is it different than Add
?
Add means "add if not already present", meaning that if something's already there, leave it (and the formatting alone). Force means add if not present, and reformat if it is present:
// Original
if (cond) {
func();
}
// Add curly braces (already present, leaves formatting alone)
if (cond) {
func();
}
// Force curly braces
if (cond) {
func();
}
Or another example:
// Original
if (cond)
func();
// Add curly braces
if (cond) {
func();
}
// Force curly braces (behaves just like add in this case)
if (cond) {
func();
}
Add
adds if it is not there.
Remove
removes if it is there.
Force
does a remove
then an add
.
As "Add or remove X between A and B"
Add
: only adds a X when there is no X appeared
AB -> AXB
AXB -> AXB
AXXB -> AXXB
Remove
: removes all appeared X
AB -> AB
AXB -> AB
AXXB -> AB
Force
: as edwinc said Remove
then Add
-> Removes all (any) X first and
adds a X finally
AB -> AXB
AXB -> AB -> AXB
AXXB -> AB -> AXB
But sometimes 'add X' may be defined as add some number X elsewhere, so Force
will like a "reformat" as Chris said.
© 2022 - 2024 — McMap. All rights reserved.