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:
- Open Visual Studio project and collapse all the folder and make it handy.
- Now press “ Control + Shift + H “ key combination and you can see the Popup which shows Find and Replace options.
- 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.
- In the replace field leave it empty so nothing will be replaced rather remove the empty blank lines.
- 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.
No Comments
I would like to start a free WordPress blog within the WordPress site (not my very own domain) yet I can't stand the designs they provide. Am i able to use a downloaded theme on the website? I have seen some WordPress hosted sites with different designs, so it appears like it's possible..
Youre so cool!