Remove extra leading spaces in single-line comments in Eclipse

放肆的年华 提交于 2019-12-08 08:34:45

问题


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 .

  1. press ctrl+F
  2. check Regular expressions option
  3. In find box put //\s+ and in replace box put //
  4. Do Find Replace or Replace all
  5. 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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!