Using Find And Replace In Eclipse IDE

Java programmers usually searches for some methods, keywords or even identifiers in the source files, project or in the workspace as a whole. The search capability uses an index of Java code in your workspace that needs to be kept up-to-date, Independent of Java builds, Means you don’t have to select the “Build Automatically” preference or need to save your modifications in order to do a search.

Searching In A File

To search for some text in a file in the active editor.

Perform the following operations.

  1. Select “ Edit ” – > “ Find/Replace”, or press “ Ctrl+F ”. Following screen will be shown Find/Replace.
  2. Enter the string to be searched .You can also use “ Replace / Replace All ” feature. Direction, Options, Scope can be useful as per the search requirement.
  3. After searching the string the first match is selected in the editor. Press “ Ctrl+K ” to find the next occurrence of the text or just press “ Enter ” .

Searching In Workspace
To search some Java element use “ Search ” – > “ Search” or press “ Ctrl+H ” and then select the Java element to search into entire workspace or a subset of it.

  1. File Search
    • “ Replace ” will replace string for the current selection.
    • “ Replace All in File ” will replace all string matches in the current file.
    • “ Skip File ” will skip the current file.
  2. There are various options on the screen, As you can see. Using “File Search” option any type of file can be searched in workspace or in any particular subset of workspace. For that you can create new “ Working set ” or choose an existing one.The very nice feature is that if you want to replace some string present in all files then “ Replace ” button will play a good role. Just enter the string to be replaced and press “ Replace ” button. All occurrences will be shown at search window and following window will be shown where user can select options while replacing text in a particular file.

    Some Details about the options are

  3. Java Search
  4. Using “ Java Search ” option any string can be searched but in Java elements only like method, package etc.