Config Key: multiline_ternary
Description: Enforces new lines between the operands of a ternary expression
Available since version: 0.7.0 (Current: )
Type: string
Default: "always"
Allowed values: "always"
or "always-multiline"
or "never"
Support
Languages: C#, EJS, JSX, Java, JavaScript, Riot, Swig, Twig, TypeScript
Beautifiers: Pretty Diff
Comparison Table
Examples
Invisible characters are shown with the following symbols:
Carriage Return = ␍; Line Feed = ␊; Tab = ⇥; Whitespace = ·.
🚧 Original Code
int·x·=·20,·y·=·10;␊
␊
var·result·=·x·>·y·?·x·:·y;␊
␊
Console.WriteLine(result);␊
🔧 "always"
Using Pretty Diff beautifier:
int·x·=·20,␊
y·=·10;␊
␊
var·result·=·x·>·y␊
··?·x␊
··:·y;␊
␊
Console.WriteLine(result);␊
How to configure
A .unibeautify.json
file would look like the following:
{
"C#": {
"indent_size": 2,
"indent_char": " ",
"multiline_ternary": "always",
"beautifiers": [
"Pretty Diff"
]
}
}
Difference from original
@@ -1,5 +1,8 @@
-int·x·=·20,·y·=·10;␊
+int·x·=·20,␊
+y·=·10;␊
␊
-var·result·=·x·>·y·?·x·:·y;␊
+var·result·=·x·>·y␊
+··?·x␊
+··:·y;␊
␊
Console.WriteLine(result);␊
🔧 "always-multiline"
Using Pretty Diff beautifier:
int·x·=·20,␊
y·=·10;␊
␊
var·result·=·x·>·y␊
··?·x␊
··:·y;␊
␊
Console.WriteLine(result);␊
How to configure
A .unibeautify.json
file would look like the following:
{
"C#": {
"indent_size": 2,
"indent_char": " ",
"multiline_ternary": "always-multiline",
"beautifiers": [
"Pretty Diff"
]
}
}
Difference from original
@@ -1,5 +1,8 @@
-int·x·=·20,·y·=·10;␊
+int·x·=·20,␊
+y·=·10;␊
␊
-var·result·=·x·>·y·?·x·:·y;␊
+var·result·=·x·>·y␊
+··?·x␊
+··:·y;␊
␊
Console.WriteLine(result);␊
🔧 "never"
Using Pretty Diff beautifier:
int·x·=·20,␊
y·=·10;␊
␊
var·result·=·x·>·y·?·x:·y;␊
␊
Console.WriteLine(result);␊
How to configure
A .unibeautify.json
file would look like the following:
{
"C#": {
"indent_size": 2,
"indent_char": " ",
"multiline_ternary": "never",
"beautifiers": [
"Pretty Diff"
]
}
}
Difference from original
@@ -1,5 +1,6 @@
-int·x·=·20,·y·=·10;␊
+int·x·=·20,␊
+y·=·10;␊
␊
-var·result·=·x·>·y·?·x·:·y;␊
+var·result·=·x·>·y·?·x:·y;␊
␊
Console.WriteLine(result);␊
No example found. Please submit a Pull Request!
🚧 Original Code
const·val1·=·a·?·"yes"·:·"no";␊
const·val2·=·a·?·(·b·?·"yes"·:·"no")·:·"maybe";␊
🔧 "always"
Using Pretty Diff beautifier:
const·val1·=·a␊
··?·"yes"␊
··:·"no"
const·val2·=·a␊
··?·(␊
····b␊
····?·"yes"␊
····:·"no")␊
··:·"maybe"
How to configure
A .unibeautify.json
file would look like the following:
{
"JSX": {
"indent_size": 2,
"indent_char": " ",
"multiline_ternary": "always",
"beautifiers": [
"Pretty Diff"
]
}
}
Difference from original
@@ -1,2 +1,9 @@
-const·val1·=·a·?·"yes"·:·"no";␊
-const·val2·=·a·?·(·b·?·"yes"·:·"no")·:·"maybe";␊
+const·val1·=·a␊
+··?·"yes"␊
+··:·"no";␊
+const·val2·=·a␊
+··?·(␊
+····b␊
+····?·"yes"␊
+····:·"no")␊
+··:·"maybe";␊
🔧 "always-multiline"
Using Pretty Diff beautifier:
const·val1·=·a␊
··?·"yes"␊
··:·"no"
const·val2·=·a␊
··?·(␊
····b␊
····?·"yes"␊
····:·"no")␊
··:·"maybe"
How to configure
A .unibeautify.json
file would look like the following:
{
"JSX": {
"indent_size": 2,
"indent_char": " ",
"multiline_ternary": "always-multiline",
"beautifiers": [
"Pretty Diff"
]
}
}
Difference from original
@@ -1,2 +1,9 @@
-const·val1·=·a·?·"yes"·:·"no";␊
-const·val2·=·a·?·(·b·?·"yes"·:·"no")·:·"maybe";␊
+const·val1·=·a␊
+··?·"yes"␊
+··:·"no";␊
+const·val2·=·a␊
+··?·(␊
+····b␊
+····?·"yes"␊
+····:·"no")␊
+··:·"maybe";␊
🔧 "never"
Using Pretty Diff beautifier:
const·val1·=·a·?·"yes"·:·"no";␊
const·val2·=·a·?·(b·?·"yes"·:·"no")·:·"maybe";␊
How to configure
A .unibeautify.json
file would look like the following:
{
"JSX": {
"indent_size": 2,
"indent_char": " ",
"multiline_ternary": "never",
"beautifiers": [
"Pretty Diff"
]
}
}
Difference from original
@@ -1,2 +1,2 @@
const·val1·=·a·?·"yes"·:·"no";␊
-const·val2·=·a·?·(·b·?·"yes"·:·"no")·:·"maybe";␊
+const·val2·=·a·?·(b·?·"yes"·:·"no")·:·"maybe";␊
🚧 Original Code
String·val1·=·a·!=·null·?·"yes"·:·"no"
String·val2·=·a·!=·null·?·(·b·!=·null·?·"yes"·:·"no")·:·"maybe"
🔧 "always"
Using Pretty Diff beautifier:
String·val1·=·a·!=·null␊
··?·"yes"␊
··:·"no"
String·val2·=·a·!=·null␊
··?·(␊
····b·!=·null␊
····?·"yes"␊
····:·"no")␊
··:·"maybe"
How to configure
A .unibeautify.json
file would look like the following:
{
"Java": {
"indent_size": 2,
"indent_char": " ",
"multiline_ternary": "always",
"beautifiers": [
"Pretty Diff"
]
}
}
Difference from original
@@ -1,2 +1,9 @@
-String·val1·=·a·!=·null·?·"yes"·:·"no";␊
-String·val2·=·a·!=·null·?·(·b·!=·null·?·"yes"·:·"no")·:·"maybe";␊
+String·val1·=·a·!=·null␊
+··?·"yes"␊
+··:·"no";␊
+String·val2·=·a·!=·null␊
+··?·(␊
+····b·!=·null␊
+····?·"yes"␊
+····:·"no")␊
+··:·"maybe";␊
🔧 "always-multiline"
Using Pretty Diff beautifier:
String·val1·=·a·!=·null␊
··?·"yes"␊
··:·"no"
String·val2·=·a·!=·null␊
··?·(␊
····b·!=·null␊
····?·"yes"␊
····:·"no")␊
··:·"maybe"
How to configure
A .unibeautify.json
file would look like the following:
{
"Java": {
"indent_size": 2,
"indent_char": " ",
"multiline_ternary": "always-multiline",
"beautifiers": [
"Pretty Diff"
]
}
}
Difference from original
@@ -1,2 +1,9 @@
-String·val1·=·a·!=·null·?·"yes"·:·"no";␊
-String·val2·=·a·!=·null·?·(·b·!=·null·?·"yes"·:·"no")·:·"maybe";␊
+String·val1·=·a·!=·null␊
+··?·"yes"␊
+··:·"no";␊
+String·val2·=·a·!=·null␊
+··?·(␊
+····b·!=·null␊
+····?·"yes"␊
+····:·"no")␊
+··:·"maybe";␊
🔧 "never"
Using Pretty Diff beautifier:
String·val1·=·a·!=·null·?·"yes"·:·"no"
String·val2·=·a·!=·null·?·(b·!=·null·?·"yes"·:·"no")·:·"maybe"
How to configure
A .unibeautify.json
file would look like the following:
{
"Java": {
"indent_size": 2,
"indent_char": " ",
"multiline_ternary": "never",
"beautifiers": [
"Pretty Diff"
]
}
}
Difference from original
@@ -1,2 +1,2 @@
String·val1·=·a·!=·null·?·"yes"·:·"no";␊
-String·val2·=·a·!=·null·?·(·b·!=·null·?·"yes"·:·"no")·:·"maybe";␊
+String·val2·=·a·!=·null·?·(b·!=·null·?·"yes"·:·"no")·:·"maybe";␊
🚧 Original Code
const·val1·=·a·?·"yes"·:·"no";␊
const·val2·=·a·?·(·b·?·"yes"·:·"no")·:·"maybe";␊
🔧 "always"
Using Pretty Diff beautifier:
const·val1·=·a␊
··?·"yes"␊
··:·"no"
const·val2·=·a␊
··?·(␊
····b␊
····?·"yes"␊
····:·"no")␊
··:·"maybe"
How to configure
A .unibeautify.json
file would look like the following:
{
"JavaScript": {
"indent_size": 2,
"indent_char": " ",
"multiline_ternary": "always",
"beautifiers": [
"Pretty Diff"
]
}
}
Difference from original
@@ -1,2 +1,9 @@
-const·val1·=·a·?·"yes"·:·"no";␊
-const·val2·=·a·?·(·b·?·"yes"·:·"no")·:·"maybe";␊
+const·val1·=·a␊
+··?·"yes"␊
+··:·"no";␊
+const·val2·=·a␊
+··?·(␊
+····b␊
+····?·"yes"␊
+····:·"no")␊
+··:·"maybe";␊
🔧 "always-multiline"
Using Pretty Diff beautifier:
const·val1·=·a␊
··?·"yes"␊
··:·"no"
const·val2·=·a␊
··?·(␊
····b␊
····?·"yes"␊
····:·"no")␊
··:·"maybe"
How to configure
A .unibeautify.json
file would look like the following:
{
"JavaScript": {
"indent_size": 2,
"indent_char": " ",
"multiline_ternary": "always-multiline",
"beautifiers": [
"Pretty Diff"
]
}
}
Difference from original
@@ -1,2 +1,9 @@
-const·val1·=·a·?·"yes"·:·"no";␊
-const·val2·=·a·?·(·b·?·"yes"·:·"no")·:·"maybe";␊
+const·val1·=·a␊
+··?·"yes"␊
+··:·"no";␊
+const·val2·=·a␊
+··?·(␊
+····b␊
+····?·"yes"␊
+····:·"no")␊
+··:·"maybe";␊
🔧 "never"
Using Pretty Diff beautifier:
const·val1·=·a·?·"yes"·:·"no";␊
const·val2·=·a·?·(b·?·"yes"·:·"no")·:·"maybe";␊
How to configure
A .unibeautify.json
file would look like the following:
{
"JavaScript": {
"indent_size": 2,
"indent_char": " ",
"multiline_ternary": "never",
"beautifiers": [
"Pretty Diff"
]
}
}
Difference from original
@@ -1,2 +1,2 @@
const·val1·=·a·?·"yes"·:·"no";␊
-const·val2·=·a·?·(·b·?·"yes"·:·"no")·:·"maybe";␊
+const·val2·=·a·?·(b·?·"yes"·:·"no")·:·"maybe";␊
No example found. Please submit a Pull Request!
No example found. Please submit a Pull Request!
No example found. Please submit a Pull Request!
🚧 Original Code
const·val1·=·a·?·"yes"·:·"no";␊
const·val2·=·a·?·(·b·?·"yes"·:·"no")·:·"maybe";␊
🔧 "always"
Using Pretty Diff beautifier:
const·val1·=·a␊
··?·"yes"␊
··:·"no"
const·val2·=·a␊
··?·(␊
····b␊
····?·"yes"␊
····:·"no")␊
··:·"maybe"
How to configure
A .unibeautify.json
file would look like the following:
{
"TypeScript": {
"indent_size": 2,
"indent_char": " ",
"multiline_ternary": "always",
"beautifiers": [
"Pretty Diff"
]
}
}
Difference from original
@@ -1,2 +1,9 @@
-const·val1·=·a·?·"yes"·:·"no";␊
-const·val2·=·a·?·(·b·?·"yes"·:·"no")·:·"maybe";␊
+const·val1·=·a␊
+··?·"yes"␊
+··:·"no";␊
+const·val2·=·a␊
+··?·(␊
+····b␊
+····?·"yes"␊
+····:·"no")␊
+··:·"maybe";␊
🔧 "always-multiline"
Using Pretty Diff beautifier:
const·val1·=·a␊
··?·"yes"␊
··:·"no"
const·val2·=·a␊
··?·(␊
····b␊
····?·"yes"␊
····:·"no")␊
··:·"maybe"
How to configure
A .unibeautify.json
file would look like the following:
{
"TypeScript": {
"indent_size": 2,
"indent_char": " ",
"multiline_ternary": "always-multiline",
"beautifiers": [
"Pretty Diff"
]
}
}
Difference from original
@@ -1,2 +1,9 @@
-const·val1·=·a·?·"yes"·:·"no";␊
-const·val2·=·a·?·(·b·?·"yes"·:·"no")·:·"maybe";␊
+const·val1·=·a␊
+··?·"yes"␊
+··:·"no";␊
+const·val2·=·a␊
+··?·(␊
+····b␊
+····?·"yes"␊
+····:·"no")␊
+··:·"maybe";␊
🔧 "never"
Using Pretty Diff beautifier:
const·val1·=·a·?·"yes"·:·"no";␊
const·val2·=·a·?·(b·?·"yes"·:·"no")·:·"maybe";␊
How to configure
A .unibeautify.json
file would look like the following:
{
"TypeScript": {
"indent_size": 2,
"indent_char": " ",
"multiline_ternary": "never",
"beautifiers": [
"Pretty Diff"
]
}
}
Difference from original
@@ -1,2 +1,2 @@
const·val1·=·a·?·"yes"·:·"no";␊
-const·val2·=·a·?·(·b·?·"yes"·:·"no")·:·"maybe";␊
+const·val2·=·a·?·(b·?·"yes"·:·"no")·:·"maybe";␊