问题
My projects in Eclipse using spaces to format code, not tabs. When commenting lines with single-line comment (pressing Ctrl+/), leading spaces just shifts to right, breaking adjustment with other non-commented lines, for example:
class Sample
{
public int x;
// public int y;
}
What I want is:
class Sample
{
public int x;
// public int y;
}
Manually removing spaces is tedious. Is there any solution for this? (plugin, some kind of macro, any other?)
I don't want to use tab-formatting.
回答1:
I was facing same problem . I found workaround for it .
- press ctrl+F
- check Regular expressions option
- In find box put //\s+ and in replace box put //
- Do Find Replace or Replace all
- Now if you want your code to be aligned just do select all (ctrl+A) then press ctrl+I
来源:https://stackoverflow.com/questions/24870271/remove-extra-leading-spaces-in-single-line-comments-in-eclipse