title: How can I remove empty lines in SQL Server Management Studio (SSMS)?
body: <p>I have many .sql files with lots of empty lines, for example,</p>
  
  <pre><code>WITH
  
    cteTotalSales (SalesPersonID, NetSales)
  
    AS
  
    (
  
      SELECT SalesPersonID, ROUND(SUM(SubTotal), 2)
  
      FROM Sales.SalesOrderHeader
  
      WHERE SalesPersonID IS NOT NULL
  
      GROUP BY SalesPersonID
  
    )
  
  SELECT
  
    sp.FirstName + ' ' + sp.LastName AS FullName,
  
    sp.City + ', ' + StateProvinceName AS Location,
  
    ts.NetSales
  
  FROM Sales.vSalesPerson AS sp
  
    INNER JOIN cteTotalSales AS ts
  
      ON sp.BusinessEntityID = ts.SalesPersonID
  
  ORDER BY ts.NetSales DESC
  </code></pre>
  
  <p>Is there a way to remove these empty lines in <a href="https://en.wikipedia.org/wiki/SQL_Server_Management_Studio" rel="nofollow noreferrer">SQL Server Management Studio</a> (SSMS)?</p>
  
  <p>This is what I would like to have:</p>
  
  <pre><code>WITH
    cteTotalSales (SalesPersonID, NetSales)
    AS
    (
      SELECT SalesPersonID, ROUND(SUM(SubTotal), 2)
      FROM Sales.SalesOrderHeader
      WHERE SalesPersonID IS NOT NULL
      GROUP BY SalesPersonID
    )
  SELECT
    sp.FirstName + ' ' + sp.LastName AS FullName,
    sp.City + ', ' + StateProvinceName AS Location,
    ts.NetSales
  FROM Sales.vSalesPerson AS sp
    INNER JOIN cteTotalSales AS ts
      ON sp.BusinessEntityID = ts.SalesPersonID
  ORDER BY ts.NetSales DESC
  </code></pre>