473,786 Members | 2,410 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

code formatting: how to clean unnecessary blank lines?

Hi,

I have to audit some c# code. I know in the options I can adjust how
the code should be formatted while entering it. But is there any way to
apply afterwards a code template to the classes to adjust their
appearance (except ctrl-k ctrl-f)? Foremost how to clear unnecessary
blank lines, e.g reduce 4 blank lines to one. I don´t want to change
every class manually.

Thanks in advance for any hint.

Regards, Andreas

Dec 4 '06 #1
4 2877
Hi Andreas,

I'm not sure what other formatting you want to do, but if you mainly
want to clear blank lines, you can do this easily by using regular
expressions, either within the IDE or using a command-line tool. Using
your example below, you could replace 4 blank lines with 1 blank line
by searching for "\n\n\n\n\n " and replacing it with "\n\n". You can do
something similar in a command-line batch file using a tool like SED.

Hope this helps,
John

Andreas Bauer wrote:
Hi,

I have to audit some c# code. I know in the options I can adjust how
the code should be formatted while entering it. But is there any way to
apply afterwards a code template to the classes to adjust their
appearance (except ctrl-k ctrl-f)? Foremost how to clear unnecessary
blank lines, e.g reduce 4 blank lines to one. I don´t want to change
every class manually.

Thanks in advance for any hint.

Regards, Andreas
Dec 4 '06 #2
Hello!

Remove unnecessary blank links using RegEx with the standard search /
replace dialog.

I'd also suggest using CTRL+K / CTRL+D (if using a standard VS 2005 layout)
to clean the source code (works for most languages). It automatically
formats your selection / document to your current configuration preferences.
If you're using a different layout, choose Edit / Advances / Format
Document.

--
With regards
Anders Borum / SphereWorks
Microsoft Certified Professional (.NET MCP)
Dec 4 '06 #3
Hi,

thanks for the hints. What I´m actually looking for is something like
the functions existing in eclipse. There you can specify how many blank
lines, where to break the line, where to put the brackets. Except blank
lines, I found everything within the configuration. But want to
eliminate all unnecessary blank lines (3,4 or 5) to one.
Is this possible too?

Thanks,

regards,

Andreas
Anders Borum schrieb:
Hello!

Remove unnecessary blank links using RegEx with the standard search /
replace dialog.

I'd also suggest using CTRL+K / CTRL+D (if using a standard VS 2005 layout)
to clean the source code (works for most languages). It automatically
formats your selection / document to your current configuration preferences.
If you're using a different layout, choose Edit / Advances / Format
Document.

--
With regards
Anders Borum / SphereWorks
Microsoft Certified Professional (.NET MCP)
Dec 4 '06 #4
Hi!

I haven't seen a generic built-in method in VS 2005 that allows you to
"clean up" the code by removing unnecessary blank lines, but it could be
accomplished with a macro. It's actually a good request for the next version
of VS 2005 (codename "orcas" scheduled for release by end 2007 am I not
mistaken).

AFAIK the macro or search/replace with regex is your best bets right now.
Could be that there is an add-in out there on the web that allows such
operations.

--
With regards
Anders Borum / SphereWorks
Microsoft Certified Professional (.NET MCP)
Dec 6 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
1811
by: j_mckitrick | last post by:
When I was reading the PEP for code, Guido suggests using blank lines 'sparingly.' Yet, in most of the 'professional' code(1) I've seen, there are often HUGE amounts of whitespace, extra blank lines, and so on. Is this the norm? Has python gravitated toward more whitespace in general? jonathon (1) Zope, RocksClusters, anaconda, and others
2
1818
by: Mike | last post by:
Greetings. I am having some difficulty with formatting a table on a web form and hope someone can help. Currently the table has a single column. Desired output format (X = text , X = number) XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX. XXXXXXXXXXXXX ### XXXXXXXX ######
235
11808
by: napi | last post by:
I think you would agree with me that a C compiler that directly produces Java Byte Code to be run on any JVM is something that is missing to software programmers so far. With such a tool one could stay with C and still be able to produce Java byte code for platform independent apps. Also, old programs (with some tweaking) could be re-compiled and ported to the JVM. We have been developing such a tool over the last 2 years and currently...
6
2981
by: shoo | last post by:
Any one know how to do this? thank Write a simple text-formatting program that produces neatly printed output from input text containing embedded command lines that determine how to format the output; all lines begin with a period are command lines. The task of the program is to collect words from input lines, fill output lines with those words, adjust the margins, and print the result. Your programs should handle the commands shown...
28
2539
by: Steve Jorgensen | last post by:
I often come up with logic like this somewhere in a function: .... If Not IsNull(<some expression>) Then <default action> Else <alternative action> End If ....
6
2749
by: shoo | last post by:
Any one know how to do this? thank Write a simple text-formatting program that produces neatly printed output from input text containing embedded command lines that determine how to format the output; all lines begin with a period are command lines. The task of the program is to collect words from input lines, fill output lines with those words, adjust the margins, and print the result. Your programs should handle the commands shown...
8
1699
by: alamb200 | last post by:
Hi I have set up a SQL database to contain alist FAQ's for our company and then plan to pull this info off using a web page. So far I have entered the data but I am unable to control how it is displayed inside SQL ie I cannot enter new blank lines I have tried using lots of spaces but this does not work when I use the website to display the info. Is there a way of formatting and editing the data in the sql database
7
1209
by: Mike | last post by:
I want to suppress blank lines in an address on a web page. At the moment, I am displaying the data like this: <asp:Label ID="Address1Label" runat="server" Text='<%# Eval("Address1")%>'></asp:Label><br /> <asp:Label ID="Address2Label" runat="server" Text='<%# Eval("Address2")%>'></asp:Label><br /> <asp:Label ID="Address3Label" runat="server" Text='<%# Eval("Address3") %>'></asp:Label><br />
9
3473
by: jd | last post by:
I am looking for python code (working or sample code) that can take an html document created by Microsoft Word and clean it up (if you've never had to look at a Word-generated html document, consider yourself lucky ;-) Alternatively, if you know of a non-python solution, I'd like to hear about it. Thanks... -- jeff
0
9647
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10360
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10163
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8988
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6744
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5397
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5532
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3668
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2894
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.