Floating FB popout byF5debug

How to remove Blank lines between codes in Visual Studio Code editor


We as developer came across multiple projects with 100s and 1000 lines of code which are written by n number of co developers. We came across the situation quite often to clean the code with the unwanted lines and spaces which makes the code pretty neat and tidy. This short tip will help to clean the code which has blank lines in a simple one click solution with out really need to go through each and every line and do a hard delete with the key board. Visual Studio Integrated development environment (IDE) is very powerful with many features which as developers we are not much considered and lazy to learn through it. One such feature is using Regular expression to do all kind of customization with in the code.

Regular expressions are simple but very powerful when you have n number of projects and solutions with 1000s of code base in place. With regular expressions you can customize the search and replacement in much easier and required format to satisfy any format that is required. Below is just a set of Regular expressions which you can use it to do some simple find and replace in your code base. We will see how to do that step by step.


Steps to remove Blank Lines:

  1. Open Visual Studio project and collapse all the folder and make it handy.
  2. Now press “ Control + Shift + H “ key combination and you can see the Popup which shows Find and Replace options.
  3. In the Find place input “^&\n” combination and select Use Regular Expression checkbox without fail as this input will mainly work with the regular expressions only.
  4. In the replace field leave it empty so nothing will be replaced rather remove the empty blank lines.
  5. In the input Find field we have give ^ for Start of the line and $ for end of line and \n which is for new line break.


About Author: Karthikeyan Anbarasan, Microsoft MVP (Most Valuable Professional) in ASP.NET/IIS Architecture. He is the Founder and Chief Editor of the www.f5debug.net website and has authored books on Windows Phone and Business Intelligence(SSIS). He is also a Passionate Speaker and a Blogger on Microsoft Technologies.

You can Join Me On: Facebook, Twitter, Google Plus, LinkedIn

Add comment

  Country flag

  • Comment
  • Preview

Recent Posts

Random Posts

Most Viewed

URL Shortner

Create your own short urls!!!

Site Counter

free counters


This is a personal weblog. The opinions expressed here represent my own and not those of my employer. For accuracy and official reference refer to MSDN/ TechNet. I have documented my personal experience on this blog.

Protected by Copyscape Web Plagiarism Finder

Site Meter