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.
The "Unindent" command corresponds to the Unindent selection entry in the Advanced sub menu of the Edit Menu . It may be called by using the keyboard shortcut "Shift+Tab". Its action is to remove the tabulation in front of each selected line if there is such a character.
Code snippet: A code snippet is any example in the documentation. It shows how to use a specific member or how to accomplish a specific task. It might be a short snippet that focuses on a specific task (for example, how to cause a button to change color using the onhover event), or a longer tutorial or how-to.
If you're using IDLE, you can use Ctrl+] to indent and Ctrl+[ to unindent.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With