Next: Editing Sources, Up: Editing Files

### 5.1 General Information

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:

Title bar
  Showing the full name of the file including path information.
Line number information
  This is the left area of the source editor. Line numbers can be disabled from the preferences. See The Preferences Dialog. Note that this area can also display additional information, such as the current line of execution when debugging, or cvs annotations.
Scrollbar
  Located on the right of the editor, it allows you to scroll through the source file.
Speed column
  This column, when visible, is located on the left of the editor. It allows you to view all the highlighted lines in a file, at a glance. For example, all the lines containing compilation errors are displayed in the Speed Column. See The Preferences Dialog for information on how to customize the behavior of the Speed Column.
Status bar
  Giving information about the file. It is divided in two sections, one on the left and one on the right of the window.
  The left section
    The first box on the left shows the current subprogram name for languages that support this capability. Currently `Ada`, `C` and `C++` have this ability. See The Preferences Dialog to enable or disable this feature.
  The right section
    If the file is maintained under version control, and version control is supported and enabled in GPS, the first box on the left will show VCS information on the file: the VCS kind (e.g. CVS), followed by the revision number, and if available, the status of the file.

    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:

    Unmodified
      The file has not been modified since the file has been loaded or saved.
    Modified
      The file has been modified since last load or save. Note that if you undo all the editing operations until the last save operation, this label will change to Unmodified.
    Saved
      The file has been saved and not modified since.

    The fifth box displays the position of the cursor in the file by a line and a column number.

Contextual menu
  Displayed when you right-click on any area of the source editor. See in particular Contextual Menus for Source Navigation for more details.
Syntax highlighting
  Based on the programming language associated with the file, reserved words and languages constructs such as comments and strings are highlighted in different colors and fonts. See The Preferences Dialog for a list of settings that can be customized.

  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.

Automatic indentation
  When enabled, lines are automatically indented each time you press the <Enter> key, or by pressing the indentation key. The indentation key is <Ctrl-Tab> by default, and can be changed in the key manager dialog, See The Key Manager Dialog.

  If a set of lines is selected when you press the indentation key, this whole set of lines will be indented.

Tooltips
  When you leave the mouse over a word in the source editor, a small window will automatically pop up if there are relevant contextual information to display about the word.

  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.

Code completion
  GPS provides two kinds of code completion: a smart code completion based on semantic information (see Smart Completion), and a text completion.

  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.

Delimiter highlighting
  When the cursor is moved before an opening delimiter or after a closing delimiter, then both delimiters will be highlighted. The following characters are considered delimiters: ()[]{}. You can disable highlighting of delimiters in the preferences.

  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.

Current line highlighting
  You can configure the editor to highlight the current line with a certain color. See The Preferences Dialog.
Current block highlighting
  If this preference is enabled, the editor will highlight the current block of code, e.g. the current `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.

Block folding
  When enabled, the editor will display `-` 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.

Auto save
  You can configure the editor to periodically save modified files. See autosave delay for a full description of this capability.
Automatic highlighting of entities
  When the cursor is positioned on an entity in the source editor, GPS will highlight all references to this entity in the current editor.

  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.