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 568019
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T13:08:42+00:00 2026-05-13T13:08:42+00:00

There are times that I have a code snippet that I want to post

  • 0

There are times that I have a code snippet that I want to post on a defect tracker, wiki, forum, etc. but it’s deeply indented in the code. I usually have to highlight the code snippet, hit <shift>-<tab> until the indents aren’t so bad, then copy/paste and then revert the code. It gets somewhat painful.

Is there a tool that can remove the tabs in front of the each line? Note that I don’t want to remove all tabs from all lines, just same preceding number of tabs from each line. I’m thinking some function of Emacs could do this.

Here’s an extreme example:

Before:

                            //This is usually some method in an anonymous inner class' anonymous inner class.
                            @Override
                            public void method(){
                                doSomething();
                            }

After:

//This is usually some method in an anonymous inner class' anonymous inner class.
@Override
public void method(){
    doSomething();
}

Notice how doSomething() still has a single tab in front of it.

  • 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-13T13:08:43+00:00Added an answer on May 13, 2026 at 1:08 pm

    Rectangle selection is my preferred way of doing this.

    Put yourself at the beginning of the first line, C-space, go to the last line, and the end of the indentation you want to remove and C-x r k (rectangular kill). That does it.

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

Sidebar

Related Questions

There are numerous times you have an interface that accepts similar type arguments that
In Javascript is there a function that returns the number of times that a
In a recent discussion on ORMs for webapps someone mentioned that there are times
Are there any products that will decrease c++ build times? that can be used
There are many times when I need to test a little snippet of .NET
Code snippet to follow. I have a struct (example code has class, tried both,
I have the following code snippet: PreparedStatement preparedStatement = connection.prepareStatement(sql); for (int i =
I have a tight loop that iterates about 500 times. In every iteration, it
I have a script that attaches actions to some objects in my HTML code.
I have a similar code snippet like this class Search { public function search($for,

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.