Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4111724
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T22:06:12+00:00 2026-05-20T22:06:12+00:00

I inherited a massive amount of code formatted as follows: void <whitespace> Foo::bar <whitespace>

  • 0

I inherited a massive amount of code formatted as follows:

void <whitespace> Foo::bar <whitespace> ( ) <whitespace> // short documentation
{
  // code
}
void Foo::bar()
{
  // code
}

with no empty line at the end of files and sometimes missing newline between functions. I’ve successfully used the following options with astyle to remove most style errors, but I can’t find any reference or documentation on how to fix these issues.

--style=ansi -t3 -N -j -k1 -z2 -n -r -H -U -p -q -w -Y -L -S

I’ve used a simple python script in the past to make sure that there are a newline at the end, and I guess that I could use something like it again together with regex to remove whitespace and add newlines, but since I use astyle now it would be great if it could do it, so… suggestions?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T22:06:12+00:00Added an answer on May 20, 2026 at 10:06 pm

    I don’t know what platform you’re using, but if you’re on any type of NIX-based platform, you have access to a lot of text-editing tools such as sed, meaning you don’t have to roll your own code to do it.

    I’m not great with regex, but the general syntax for sed search and replace on the command line is this:

    sed -i -e 's/expr1/expr2/g' filename
    

    This will replace “expr1” with “expr2”. It works with spaces and regex, so you can condense all multiple spaces into one space (or none, if you don’t type anything for expr2).

    sed may have what you need to deal with your newlines, but unfortunately, I’m not that skilled with its language.

    Good luck, though.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I inherited an ASP.NET application that builds pages with massive viewstate values. As I
I inherited 2 JSP projects (tomcat) in my eclipse with common code that is
We've just inherited a massive client project that is in VS.NET 2003. We typically
I've inherited a asp.net project and I'm finding that the code behind pages contain
I inherited a project stored in CVS. The previous developer has massive un-committed changes
I inherited a javascript code base and I am new to javascript. So i
i inherited this code from some-one and this only returns the first row it
Suppose you have inherited a massive spreadsheet which contains lots and lots of data.
I inherited sites where previous developer used the spaghetti code below to handle relative
I inherited some legacy Java (1.4) code and this design decision appears regularly. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.