0

Is it possible to remove all white space at the beginning of a line/s?

Sometimes, when I copy and paste code, there will be a mixture of tabs and spaces which upsets the spacing format I already have. So it would be great if there was a way to delete all the starting white space so I can re-indent it myself.

A. L
  • 11,695
  • 23
  • 85
  • 163

2 Answers2

1

Usually you can un-indent code in Eclipse by selecting it and hitting/holding Shift+Tab.

Alternatively you can use Ctrl+i to re-indent or Ctrl+Shift+f to re-format your code based on your formatting settings (see also this answer).

But that may depend on the Editor for the type of code/document you're working on.

Community
  • 1
  • 1
Markus Mitterauer
  • 1,560
  • 1
  • 14
  • 28
  • I already know about the shift + tab, but the ctrl shift f really helped. Though I think I'm still looking for the magic "remove all leading white spaces" button. – A. L Sep 21 '16 at 06:13
  • 1
    @A.Lau Did some research and I'm afraid there's no default feature in Eclipse for what you're looking. There's [one for trailing whitepaces](http://eclipsesource.com/blogs/2012/10/08/how-to-deal-with-whitespaces-in-the-eclipse-ide/), but none I could find for leading whitespace. There may exist a plug-in which provides the desired functionality, but I don't know any. Personally I use [Notepad++](https://notepad-plus-plus.org/) (Menu Edit / Blank operations) for text-operations like that. – Markus Mitterauer Sep 21 '16 at 08:19
  • Thanks anyhow. I'll just use the ctrl shift f and make due. – A. L Sep 22 '16 at 01:29
0

If you're on a linux computer you can use this command:

$ cat input.txt | sed 's/[ \t]*$//' > output.txt
nwfistere
  • 355
  • 4
  • 15
  • Not quite what I want as I might insert it into the middle of a text document and stuff. And I'm using the Eclipse as my IDE – A. L Sep 21 '16 at 05:26