Eclipse Gems, Tips & Tricks: Code Completion

This article is part of a ‘mini series’ about hidden gems, tips and tricks around Eclipse.
The topic of this one is how use Code Completion in the editor.

Library Code Completion

Library Code Completion

One of the most powerful helpers of an IDE is Code Completion: the automatic completion of what I start writing in code.

In Eclipse this feature is accessible with <CTRL>+<SPACE> while writing in the Editor View. It works pretty much everything:

Type

#inc

and then press <CTRL>+<SPACE> and it completes it to

#include

Add the double quotes and hit again <CTRL>+<SPACE> and it gives you a list of possible choices:

Choices for includes

Choices for includes

Continue typing and it narrows down the list to the remaining choices:

Reduced List

Reduced List

Use the cursor up/down to select an item in the list and hit enter to use it:

Cursor Navigation in List

Cursor Navigation in List

Start typing a library function call and it shows you the prototype including a help text:

Library Code Completion

Library Code Completion

Inside a function call, <CTRL>+<SHIFT>+<SPACE> will show the parameter names:

Showing parameter names

Showing parameter names

The same without the <SHIFT> automatically fills in the names:

Completed Parameter Names

Completed Parameter Names

Start typing a language keyword and it helps you on that too:

language code completion

language code completion

Enter ‘switch’ and it will fill out a template for you:

filled out switch template

filled out switch template

Same thing for variables of any kind: start typing and it shows the struct members:

Variable Type Code Completion

Variable Type Code Completion

It is really that easy: start with something and hit <CTRL>+<SPACE> and you get suggestions what can be added.

Happy completing 🙂

Links

 

15 thoughts on “Eclipse Gems, Tips & Tricks: Code Completion

    • Hi myke,
      great! This confirms that such tips can be useful. Code Completion is one of the very useful features of most IDE, and definitely for me the most used one in Eclipse.

      Like

  1. I use custom templates for tagging changes in code, because there can be a lot of them. The content might be something like:
    // [RD] V1.23 ${cursor}
    in the C/C++ context, and
    [RD] V1.23 ${cursor}
    in the comment context. I call them ‘tag’, so it’s “tag+”. tSaves me a bucket of time.
    Hope it helps someone.
    One thing I’d like to do is make the “V1.23” a custom parameter (so I only have to edit it once), but I haven’t figured that one out yet.

    Liked by 1 person

  2. Pingback: Eclipse Gems, Tips & Tricks: Working Sets | MCU on Eclipse

  3. Pingback: Eclipse Gems, Tips & Tricks: Block Comments | MCU on Eclipse

  4. Pingback: Eclipse Gems, Tips & Tricks: Highlight Usage and Definition | MCU on Eclipse

  5. Pingback: Eclipse Gems, Tips & Tricks: Faster Debugger Start | MCU on Eclipse

  6. Pingback: Eclipse Gems, Tips & Tricks: Project Filter | MCU on Eclipse

  7. Pingback: Eclipse Gems, Tips & Tricks: Text Block Selection | MCU on Eclipse

  8. Pingback: Eclipse Gems, Tips & Tricks: Close and Open Projects | MCU on Eclipse

  9. Pingback: Eclipse Gems, Tips & Tricks: Importing Projects | MCU on Eclipse

  10. Pingback: Eclipse Gems, Tips & Tricks: Code Folding | MCU on Eclipse

What do you think?

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.