How to remove empty lines in Visual Studio Code image
Posted on 19 Oct 2018

How to remove empty lines in Visual Studio Code

Trying to figure out a way to remove those extra blank new lines in Visual Studio code is really simple. The method is similar to other IDE.

Visual Studio Code is fantastic code editor. It has most of the features of a good IDE and it's free. Today I opened a code file of a developer and found out that there were many empty lines between programming expressions. In order to reduce the total number of lines I wanted to delete the extra lines.

Method 1:

Here are step by step instructions to remove those empty lines.

  1. Open your code in Visual Studio Code
  2. From Edit Menu, select Replace or use a short cut key (command + Option + F on Mac or Ctrl + H on Windows)
  3. In the find box type \n\n
  4. In the replace box type \n
  5. Make sure the 'Use Regular Expression' is selected
  6. Select 'Replace All' button
     

Method 2:

The above method should remove all the empty line however, if it didn’t then follow these steps:

  1. Open your code in Visual Studio Code
  2. From Edit Menu, select Replace or use a short cut key (command + Option + F on Mac or Ctrl + H on Windows)
  3. In the find box type ^(\s)*$\n
  4. Leave the replace box empty
  5. Make sure the 'Use Regular Expression' is selected
  6. Select 'Replace All' button 

If you can't find the above steps, here is a picture.

 

How to remove empty lines in Visual Studio Code

 

0 comments

Add your comment

In reply to