<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/126543>126543</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
clang-format: add option to preserve indentation-only whitespace lines
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang-format
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
seanm
</td>
</tr>
</table>
<pre>
Unless I'm missing it, clang-format has no option to keep whitespace-only lines that keep indentation level with the code.
The bullets represent spaces. I'm looking for a way to *not* have the indentation-only line 3 be changed:
```c
if (true) {
••••int myNum = 2;
••••
••••myNum = 4;
}
```
Always becomes:
```c
if (true) {
••••int myNum = 2;
••••myNum = 4;
}
```
Xcode has an option (default I think) to create/preserve such indentation, in Xcode > Settings > Text Editing > Editing:
```
While Editing: ☑ Automatically trim trailing spaces
☑ Including whitespace-only lines
```
Xcode's "re-indent" command also adds such indentation, and so all my code has such indentation, hence I'd like clang-format to not touch it.
(I've seen others want the same, ex: https://stackoverflow.com/questions/32619716/clang-format-is-removing-all-the-indent-spaces-on-my-empty-lines)
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJy8VE2P4zYM_TXKhXDg0IkTH3zwdibAXHrpFu1VlulYjT5SiU7W_76Qnd1ksLPFHooGAfxFPj0-PlLGqE-OqBa7T2L3spIjDz7UkaSzq9Z3U_27MxQjvAncW7A6Ru1OoFngL6CMdKes98FKhkFGcB78hbV3wB7ORBe4DZopXqSizDszgdGOIvAgefmuXUeO5Zxj6EoGbpoH4IFA-Y7WIm9E3nweCNrRGOIIgS6BIjmGGTau79SM9-dErfcBJNzklDgIbJxngQ0M8koz7NOJD0pQQEugBulO1ImiWY4VZb78lcgb3YPAA4eRBFYg9p8gRbyiOOSiwX-50Y7BTr-OFkTxAiiKTz-Z-JNhD-ztHXv_8kx-qaUxNzlFaEl5S_F_KfG_pP9ncsPsMem-ekzgoaNejobhDXjQ7pxoswcVSDIJPM5OCVeCOKrhufPJvdrBgiqKV_iNmLU7xfnhM31heO10ejO_uN9_r5rImz8GbegpAiCVVh1EtYFmZG8layWNmYCDtsBBapNwF_dCkhh--HtAvTllxi4lfjhSP1BM4D6CQAyULdULRFDeWuk6kCZ6kF0XP5QnRaTvxoCd4Jv8H4UO5BTNY9iB0Wd6vxjYg_PpMmfyfaQFHlJC6g2RA88DhQg36Xie0igtJWj6kiQdmC-zZ_Eo8BhZqrO_UuiNv62VtwKPf48UE50o8Fhguan2m1Lg8ZlIpmMWyPqrdqdMGpPx8FWVbGlG5l1mp4zshadskRWrVVcXXVVUckX1Zl9UmO-qqlwNtZIKZVt1xe7Q9kW-VZU6UFm0h7zf7Pq2Xekac9zluMk35bYsyjX1Ra92xaGX2G1pU4ptTlZqszbmatc-nFY6xpHqDZa7bbEysiUT582M-FyJQEy7OtQpL2vHUxTb3OjI8YHEmg3V77KKJnX7aUN_G4_vduLDY4u9VmMw9fsunDQPY3uXPx17v2SX4P8ixQKPczWpI_eCrjX-EwAA__87e_VQ">