Learning the vi Editor

Learning the vi EditorSearch this book
Previous: 10.3 Online Help and Other DocumentationChapter 10
elvis
Next: 10.5 Multiwindow Editing
 

10.4 Initialization

This section describes elvis's session files and itemizes the steps it takes during initialization.

10.4.1 The Session File

elvis is intended to eventually meet COSE (Common Open System Environment) standards. These require that programs be able to save their state and return to that saved state at a later time.

To be able to do this, elvis maintains all its state in a session file. Normally elvis creates the session file when it starts, and removes it when it exits, but if elvis crashes, a left-over session file can be used to implement recovery of the edited files.

10.4.2 Initialization Steps

elvis performs the following initialization steps. Interestingly, much of the customization for elvis is moved out of editor options and into initialization files.

  1. Initialize all hardcoded options.

  2. Select an interface from those compiled into elvis. elvis will choose the "best" of the ones that are compiled in and that can work. For example, the X11 interface is considered to be better than the termcap interface, but it may not be usable if X Windows is not currently running.

    The selected interface can process the command line for initialization options that are specific to it.

  3. Create the session file if it doesn't exist; otherwise, read it (in preparation for recovery).

  4. Initialize the elvispath option from the ELVISPATH environment variable. Otherwise, give it a default value. "~/.elvislib:/usr/local/lib/ elvis" is a typical value, but the actual value will depend upon how elvis was configured and built.

  5. Search elvispath for an ex script named elvis.ini and run it. The default elvis.ini file performs the following actions:

    • Chooses a digraph table based on the current operating system. (Digraphs are a way to define the system's extended ASCII character set and how characters from the extended set should be entered.)

    • Sets options based on the program's name (for example, ex vs. vi mode).

    • Handles system-dependent tweaks, such as setting the colors for X11 and adding menus to the interface.

    • Picks an initialization filename, either .exrc for UNIX, or elvis.rc for non-UNIX systems. Call this file f.

    • If the EXINIT environment variable exists, executes its value. Otherwise, :source ~/f, where f is the filename chosen previously.

    • If the exrc option has been set, then runs the :safer command on f in the current directory.

    • For X11, sets the normal, bold, and italic fonts, if they have not been set already.

  6. Load the pre- and post-read and pre- and post-write command files, if they exist. Also load the elvis.msg file. All of these files are described later in this chapter.

  7. Load and display the first file named on the command line.

  8. If the -a option was given, load and display the rest of the files, each in its own window.


Previous: 10.3 Online Help and Other DocumentationLearning the vi EditorNext: 10.5 Multiwindow Editing
10.3 Online Help and Other DocumentationBook Index10.5 Multiwindow Editing

The UNIX CD Bookshelf NavigationThe UNIX CD BookshelfUNIX Power ToolsUNIX in a NutshellLearning the vi Editorsed & awkLearning the Korn ShellLearning the UNIX Operating System