Source editing is one of the central parts of GPS, giving in turn access to many other functionalities, including extended source navigation and source analyzing tools.
The integrated source editor provides all the usual capabilities found in integrated environments, including:
Ada
, C
and C++
have this ability. See The Preferences Dialog to enable or
disable this feature.
The second box shows the current editing mode. This is either Insert or Overwrite and can be changed using the insert keyboard keys by default.
The third box shows the writable state of the file. You can change this state by clicking on the label directly: this will switch between Writable and Read Only. Note that this will not change the permissions of the file on disk, it will only change the writable state of the source editor within GPS.
When trying to save a file which is read only on the disk, GPS will ask for confirmation, and if possible, will force saving of the file, keeping its read only state.
The fourth box shows whether the file has been modified since the last save. The three possible states are:
The fifth box displays the position of the cursor in the file by a line and a column number.
By default, GPS knows about many languages. You can also easily add support
for other languages through XML files. Most languages supported by GPS
will provide syntax highlighting in the editor.
If a set of lines is selected when you press the indentation key, this whole
set of lines will be indented.
The type of information displayed depends on the current state of GPS.
In normal mode, the entity kind and the location of declaration is displayed when this information is available. That is, when the cross-reference information about the current file has been generated. If there is no relevant information, no tooltip is displayed. See Support for Cross-References for more information.
In addition, the documentation for the entity is displayed. This is the block of comments just before or just after the entity's declaration of body. There mustn't be any blank line between the two. For instance, the following are valid documentation for Ada and C:
-- A comment for A A : Integer; B : Integer; -- A comment for B C : Integer; -- Not a comment for C, there is a blank linke
In debugging mode, the value of the variable under the mouse is displayed in the pop up window if the variable is known to the debugger. Otherwise, the normal mode information is displayed.
You can disable the automatic pop up of tool tips in the Editor section of
the preferences dialog. See The Preferences Dialog.
It is useful when editing a file and using often the same words to get automatic word completion. This is possible by typing the <Ctrl-/> key combination (customizable through the key manager dialog) after a partial word: the next possible completion will be inserted in the editor. Typing this key again will cycle through the list of possible completions.
Text completions are searched in all currently open source files, by first
looking at the closest words and then looking further in the source as needed.
You can also jump to a corresponding delimiter by using the <Ctrl-'> key,
that can be configured in the preferences. Typing twice on this key will move
the cursor back to its original position.
begin...end
block, or loop statement,
etc...
The block highlighting will also take into account the changes made in your source code, and will recompute automatically the current block when needed.
This capability is currently implemented for Ada, C and C++ languages.
-
icons on the left side,
corresponding to the beginning of subprograms. If you click on one of these
icons, all the lines corresponding to this subprogram are hidden, except
the first one. As for the block highlighting, these icons are recomputed
automatically when you modify your sources and are always kept up to date.
This capability is currently implemented for Ada, C and C++ languages.
When the cursor moves away from the entity, the highlighting is removed.
This is controlled by the plugin auto_highlight_occurrences.py
: it can
be deactivated by deactivating the plugin (see The Plug-ins Editor).
Details such as presence of indications in the Speed Column or highlighting
color can be customized in the Plugins
section of
The Preferences Dialog.
GPS also integrates with existing third party editors such as
Emacs
or vi
. See Using an External Editor.