Edit (Debugging with ROCGDB)

Next: Search, Previous: Specify Location, Up: Source [Contents][Index]

### 9.3 Editing Source Files

To edit the lines in a source file, use the `edit` command. The editing program of your choice is invoked with the current line set to the active line in the program. Alternatively, there are several ways to specify what part of the file you want to print if you want to see other parts of the program:

`edit location`

  Edit the source file specified by `location`. Editing starts at that location, e.g., at the specified source line of the specified file. See Specify Location, for all the possible forms of the location argument; here are the forms of the `edit` command most commonly used:

  `edit number`

    Edit the current source file with number as the active line number.

  `edit function`

    Edit the file containing function at the beginning of its definition.

#### 9.3.1 Choosing your Editor

You can customize ROCGDB to use any editor you want 10. By default, it is `/bin/ex`, but you can change this by setting the environment variable `EDITOR` before using ROCGDB. For example, to configure ROCGDB to use the `vi` editor, you could use these commands with the `sh` shell:

    EDITOR=/usr/bin/vi
    export EDITOR
    gdb …

or in the `csh` shell,

    setenv EDITOR /usr/bin/vi
    gdb …

#### Footnotes

### (10)

The only restriction is that your editor (say `ex`), recognizes the following command-line syntax:

    ex +number file

The optional numeric value +number specifies the number of the line in the file where to start editing.