Remove source file comments using IntelliJ?

后端 未结 6 1182
醉话见心
醉话见心 2020-11-29 16:47

Is there a plugin or tool in IntelliJ that will strip all comments out of your source .java files? I\'ve read about an ANT task that can do this.. was looking to do the sa

6条回答
  •  有刺的猬
    2020-11-29 17:21

    Late to the party but there is "Structural Search and Replace Dialogs" option that can be used to search different kind of comments and replace them

    Go to Edit => Find => Replace Structurally...

    • Enter one of below in "Search Template:"

    Single line

    // $CommentContent$ 
    

    Multi line

    /*
      $CommentContent$ 
    */
    

    Javadoc

    /**
      $CommentContent$ 
    */
    
    • Leave the "Replacement Template:" blank

    • Select appropriate Scope

    • Click 'Find' and then 'Replace all'

    • you Should see no more comments

    Note: that this might mess up formatting so you will have to reformat affected code

提交回复
热议问题