Eclipse Features
Hover
If you momentarily pause a mouse over a variable, named constant or a
function invocation in the editor view of Eclipse, Eclipse pops up a
window describing the construct. A variable, it shows its type, for a
predefined function, it shows the number and types of arguments the
function takes and its return value. For a function, you can have
eclipse open the source file where this function is defined by
pressing F3.
Refactoring
Refactoring is modifying the program structure without altering its
behavior. Often refactoring is done to "clean up" or improve the
readability of the program. Eclipse automates certain refactoring
functions. For example, Eclipse allows changing the name of the
variable, function or another construct throughout the project. To
rename the variable right-click on it and select Refactor -->
Rename.
Formatting
Eclipse CDT can automatically correct the indentation of the source
file. To do that select Source --> Format. By default CDT
uses K&R (Kernighan and Ritchie - the C language creators) style
of indentation. To change CDT formatting style go to Window -->
Preferences --> C/C++ --> Code Style.
Code Completion
Code completion is part of Eclipse/CDT feature called content
assist. It minimizes the number of keystrokes you need to type to
enter standard code constructs. Code completion provides variants of
possible completion on the bases of the current context, scope and
already typed prefix.
Code completion works for: fields, variables, methods, functions,
classes, structures, namespaces, standard constructs such
as for, etc.
Code completion can be activated explicitly by
pressing ctrl+space or right clicking and then
selecting Content Assist. Content assist is activated
automatically when you type ".", "->", or "::".
Code completion pops up a window with possible completion
variants. You can select the variant to be automatically inserted by
clicking on it. You can get more information about each variant by
pointing to it.
Note that for user-defined structures and other involved constructs it
may take one compilation cycle for CDT to recognize it and start
showing them in code completion window.
Code Folding
Eclipse/CDT allows the programmer to selectively hide function and
class definitions displaying only their heads (code outline). This
allows the programmer to manage large source files and focus only on
code that is relevant for the particular task at hand.
By default, code folding is disabled. To enable code folding in the
current text file: right click on the left border of the editor
window. Select Folding -> Enable Folding. Or
press Ctrl+ numpad divide. Initially, all constructs are
unfolded. Foldable constructs are marked by plus or minus signs on the
left border of the editor window. To fold construct click on the minus
sign. To unfold a construct --- click on the plus sign.
To customize folding preferences or to automatically enable code
folding on every file that is opened, go to:
Windows -> Preferences -> C/C++ -> Editor -> Folding
Tasks
Eclipse provides a way of keeping track of to-do items
called tasks. It is attached to the particular line in the
source file. A task contains a short description and a status and
priority. A task's status can be either "not completed" or
"completed". A "task" tab of the console view lists all the tasks for
the current project. To set the task on the current line either
select Edit --> Add Task or right click on left border of
the editor view at the line where you want to set the task. An icon on
the left border of the editor view indicates the presence of a
task. The task can be removed by right-clicking on it in the task view
or on its icon in the editor view.
Word Completion
Word completion is a feature provided by Eclipse in Editor
view. After typing several beginning letters, hit Alt+/
and Eclipse tries to guess at the completion of the word. For the
guess, Eclipse uses a rather sophisticated Hippie guessing algorithm:
it considers in the context, the words in the file, the file name,
etc. In practice, more 90% of the time, Eclipse guesses correctly. If
the guess is incorrect, hit Alt+/ again and Eclipse
offers the next best guess.
Keyboard Shortcut Display
Pressing ctrl+shift+L brings up a list of all available
keyboard shortcuts for the current context. For example, if you are
presently editing text, all available editor shortcuts will be displayed.