0

I've got about 200 Java files and I want to remove the following line within eclipse all over the 200 files:

public static final String ID = "@(#) $Id: LoginView.java 457 2015-10-26 12:52:10Z $";

The varibale content in this line is @(#) $Id: LoginView.java 457 2015-10-26 12:52:10Z $

How can I search for all of the lines and delete them?

What to do, if I have a commentary e.g.

//*****************************************************************************
//
//                            Copyright (c) 2015
//                            All rights reserved
//
//        The contents of this file is an unpublished work protected.
//
//        This software is proprietary to and emboddies confidential
//        technology of abc. Possession, use and copying
//        of the software and media is authorized only pursuant to a
//        valid written license. This copyright
//        statement must be visibly included in all copies.
//
//*****************************************************************************

//*****************************************************************************
//
// $Revision: 457 $ ($Date: 2015-10-26 13:52:10 +0100 (Mo, 26 Okt 2015) $)
//
// filename : LoginView.java
//
// contents :
//
//*****************************************************************************

The variable content is the last part and here it is the same: I want to remove the WHOLE commentary in eclipse in each file.

How to achieve this?

marc3l
  • 2,525
  • 7
  • 34
  • 62
  • It sounds like there are 2 questions here: remove the `ID` variable and remove the comments, is that correct? If so, you should split this question into 2 questions. – Tunaki Nov 21 '15 at 17:55
  • @Tunaki Yeah, I should split it, but I think they are really dependent. Yes I want to remove the whole variable including the value. – marc3l Nov 21 '15 at 17:59
  • Like a regex find-replace where the replace is an empty string? – OneCricketeer Nov 21 '15 at 18:00
  • Click Search -> File... . Here in the file search tab you have everything you need, including regexp checkbox on the right, file name filtering and Replace... button on the bottom. – Dmitrii Bocharov Nov 21 '15 at 18:02
  • Would either do that with a tool like sed ( http://stackoverflow.com/questions/5410757/delete-a-line-containing-a-specific-string-using-sed ) or manually: text search for `"@(#)`, then click through the results and hit `Ctrl+D` to delete the line. Takes a few seconds each but should be faster than searching for the next few minutes for a better solution. You can also use regex search and replace, e.g. for `^.*String.*"@\(#\)[^"]*";$\n`: lines that contain `String`, then `"@(#)` and end with `";` (and a new line see: http://stackoverflow.com/q/3725469/995891 ) – zapl Nov 21 '15 at 18:13
  • I don't get what you're trying to match. What is constant, what isn't ? Also, do you expect to find that line imbedded in comments as well? There is a way to parse comments if you're interested. –  Nov 21 '15 at 18:36

2 Answers2

1

You can do text search by using Ctrl+H with scope as workspace like explained in another answer, but you can use the replace within the Ctrl+H window of eclipse to achieve the deletion and don't need to use Ctrl+F.

To delete multi-line you can enable the "Regular expression"-Checkbox.

You dont have to write the Regex yourself, just mark the text and open Ctrl+H again after the activation of the checkbox.

Lordroran
  • 25
  • 7
0

You can do text search by using Ctrl+h with scope as workspace then it will be searched in all projects in the workspace and will show in search result. Now for each file do Ctrl+F and replace it.

If you are using Notepad++, then there you can search and select "Replace all in all opened documents" will replace it in all files. Hopefully it solves your search and replace problem

Naruto
  • 4,221
  • 1
  • 21
  • 32