• Home
  • C/C++ Software Development with Eclipse
    • Contents
      • Copyrights
      • Dedication
      • Preface
      • 1. Introduction
      • 2. C/C++ Software Development
      • 3. More from Eclipse
      • 4. Advanced Eclipse
      • 5. Appendix
  • Outline
      • 2.1.11.1. Simple Search
  • «2.1.11. Searc...
  • 2.1.11.2. Adv... »
  • Buy
    • Buy eBook
    • Buy Printed Book
    • Request Preview Copy

2.1.11.1. Simple Search¶

Basic search within the single source file.

Ctrl + F would bring up Find/Replace Dialogue..

../../../../_images/c-find-replace.png

Find/Replace Dialogue.

The options are self explanatory. The same dialogue can be used to replace text.

If you know regular expressions, take full advantage of it. If you don’t know, learn it.

Regular Expressions

This may not be the best example to show the full power of Regular Expressions, but here is a small example.

e.g. There is a poor code segment:

#define  uint8_t unsigned char
#define   int8_t   signed char
#define uint16_t unsigned short
#define  int16_t   signed short
#define uint32_t unsigned int
#define  int32_t   signed int

During code-review, a fairly experienced C Developer would suggest to use typedefs instead of #define

Q:

How to do it quickly?

A:

Use Regular Expressions Use these values in Find/Replace Dialogue.. We will get the desired output.

Find:#define\s+(\w+)\s+([\w ]+)$
Replace With:typedef \2 \1;

If you can’t remember the syllables of regular expressions, Eclipse would give Assistance for regular expressions. Just press Ctrl + Space.

../../../../_images/e-find-regular-expressions-assit.png

Assistance for regular expressions

A Funny quote on Regular Expression

Developer_1:

I have a problem.

(Thinks)

I will use Regular expression to fix that.

Developer_2:

(Now he has two problems.)

  • Home
  • «2.1.11. Searching / Finding
  • Back to top
  • 2.1.11.2. Advanced Search»
  • Contents

C/C++ Software Development with Eclipse(v0.8.1)

© Copyright MMIX-MMXVII Purnank Harjivanbhai Ghumalia & Meera Purnank Ghumalia.

Privacy Policy

If you have any suggestion/comment, feel free to Contact the authors with your valuable feedback.

Created using: Sphinx1.4.8,Ratatouillev0.7.08-cd0b972.

Ratatouille