How to remove blank lines in VS Code?

1

Recently I copied a file that was on a server and it looks like this, with a blank line between each line of code.

I would like to know if there is any shortcut or command to remove these empty lines by VS Code in a practical way that does not manually ...

<!-- BANNER -->

<section id="produtos"  class="container-fluid banner d-flex flex-column justify-content-center align-items-center">

  <div class="row w-100">

    <div class="col-12 text-center pt-1 pt-sm-4">

      <h2 class="tit-banner">TINTAS ESPECIAIS PARA</h2>

      <span id="app" class="texto-banner app"></span>

    </div>

  </div>

</section>



<!-- Lista Produtos -->

<section class="container mb-4">

  <div class="row mt-5">

    <div class="col-12 text-center">

      <h4 class="sec-h4 mb-3">nossa linha completa de tintas</h4>

      <h2 class="sec-h2">Temos o produto certo para te atender</h2>

    </div>

  </div>

  ...etc...

OBS: Originally this file was not so, it did not have blank lines between the lines of code, and looking directly at the source code of the page that is on the server there are also no such empty lines. ..

    
asked by anonymous 27.08.2018 / 21:37

1 answer

3

Follow these steps:

  • Press CTRL + H
  • Select "Use Regular Expression"
  • Search box: ^(\s)*$\n
  • Replace Box: Leave it blank.
  • Click Replace All.

Final result:

Visual Studio Code - delete all blank lines - regex

Regex Explanation:

  • The regex is very simple, the line should start ( ^ ) and end ( $ ) with spaces, ie it should not contain anything on the line!
27.08.2018 / 21:46