<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/97303>97303</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [clang-format] Feature Request: Newline after declarations
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            clang-format
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          Jacobfaib
      </td>
    </tr>
</table>

<pre>
    I would like to enforce that variable declarations are followed (or preceded) by `N` empty lines. To my knowledge, this is not possible to directly enforce in current (`clang-format-19`). Something like:
```yaml
EmptyLinesAroundDecls:
  Enabled: <bool>
  Before: <int>
  After: <int>
```
It would be great if this could also distinguish between empty lines after block openings, and functions calls. If I specify that I want `Before: 1` and `After: 1`, I want to ignore `Before` for block openings. Probably this requires an additional option `IgnoreBlockOpening`?
```c++
// GOOD
foo();

int x;
double y;
auto z = [] { return 0; }();

foo();

{
  int x; // Note, no empty line above OK

  foo();
}
```
```c++
// BAD (no empty lines before or after decls)
foo();
int x;
double y;
auto z = [] { return 0; }();
foo();
{

  int x; // BAD, empty line after block opening
}
```
```c++
// BAD (no empty lines after decls)
foo();

int x;
double y;
auto z = [] { return 0; }();
foo();
```
```c++
// BAD (no empty lines before decls)
foo();
int x;
double y;
auto z = [] { return 0; }();

foo();
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzEVd1y6jYQfhpxsxNGyAbiC1_gOHRoO0mn7QtI8tqoEVqOJIfSp-_IDhwn5bS9OO2Z8fCzy_5837fLyhBM5xBLtqzYsp7JPu7Jl99LTaqVRs0UNedyByfqbQPWvCBEAnQteY0Q9zLCq_RGKovQoLbSy2jIBZAeoSVr6YQNMHFPHo4eNTbYMFGAOgNb8Se24oCHYzyDNQ7DHH4lOJzhxdHJYtMhEw8Q9yaACeAowpFCMKlWJGiMRx3t-dqNcaB779HFVJCtuLbSdXct-YOMd4u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