在Eclipse中删除单行注释中的多余前导空格 [英] Remove extra leading spaces in single-line comments in Eclipse

查看:248
本文介绍了在Eclipse中删除单行注释中的多余前导空格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Eclipse中的项目使用空格设置代码格式,不是制表符。用单行注释注释行时(按 Ctrl + / ),前导空格仅向右移动,从而与其他未注释的行中断了调整,例如:

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;
}

我想要的是:

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.

推荐答案

我遇到了同样的问题。我找到了解决方法。

I was facing same problem . I found workaround for it .


  1. 按ctrl + F

  2. 检查正则表达式选项

  3. 在查找框中放入 // \s + ,在替换框中放入 //

  4. 进行查找替换或全部替换

  5. 现在,如果您想对齐代码,只需选择全部(ctrl + A),然后按ctrl + I

  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

这篇关于在Eclipse中删除单行注释中的多余前导空格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆