Changing Default Editors

As the Section Editing the Draft with prompter explained, after the comp, repl, forw, and dist commands create the draft message, they start the prompter editor. And as you saw in the Section on whatnow, typing What now? edit gives you a default editor. The following sections explain how to change these defaults.

Editor-next

When whatnow runs an editor program (a program you name at a What now? edit prompt or with an -editor switch in the MH profile), it keeps track of the editor's name. Then, after the editor (like prompter, vi, or any other editor) exits, it can have a new default editor ready to run.

You set the default editor with entries in your MH profile. For example, let's say that you have these three entries in your MH profile:

    prompter-next: vi
    vi-next: spell
    spell-next: vi
    
These tell MH that after you run prompter the default editor is vi, and that after vi the default editor is spell. Finally, after you run spell the default editor is vi again. So when you use comp (which runs prompter for you, unless you've changed that), you can go into vi directly by typing edit (or just e) at the What now? prompt. At the next What now? prompt, the default editor will be spell. Here's a demonstration:
    % comp
    To: someone
    cc:
    Subject: something
    -------
    blah blah blah...

    ^D
    -------
    What now? e
        ...vi starts...
    What now? e
        ...spell puts a list of words on the screen...
    What now? e
        ...vi starts...
    What now? e
        ...spell checks the just-edited message...
    What now? s
    
Of course, you don't have to use the default editor. You can use any other editor by typing its name after the edit (e) command.

Replacing the prompter Editor

If you don't like the way that prompter works, you can use any other UNIX text editor. (...Well, almost any editor. The editor must be able to read the draft message file and then write the edited text back to the same file. For example, the sed(1) editor won't work unless you incorporate it into a shell program that replaces the original file.)

If you never want comp, repl, forw, and dist to use the prompter editor, put an entry like this in your MH profile:

    Editor: whatever
    
where whatever is the editor you want -- vi, for example. Then, when you start comp, repl, forw, or dist, it will put you straight into vi. When you save the message and exit the editor (in vi, type ZZ), you'll be at the What now? prompt.

But prompter can be pretty handy for entering header fields when you use comp and dist, for example. To choose different editors for different commands, use their -editor switches.

Let's assume that your default editor is prompter (if you have not added an Editor: entry to your MH profile, as shown above). Then you can set the repl and forw entries in your MH profile to use emacs -- and leave prompter as the other programs' default:

    repl: -editor emacs
    forw: -editor emacs
    
Or, let's say that you want to use vi as the default editor for everything except dist (which really doesn't need a sophisticated editor). Put these two entries in your MH profile:
    Editor: vi
    dist: -editor prompter
    
The editor script named distprompter is designed to be used with dist.

By the way, if you set vi as the default editor, here's a handy key map command for vi:

    map! ^N ^[/: $^[A
    
The key map sets vi so that typing CTRL-N from text-input mode will move you to the end of the next empty field. (The map starts with an ESCAPE (^[) to go to command mode. Then, it searches for the next empty field -- that is, the next line ending with a colon and a space (/: $^[). The A command resumes text input at the end of this empty field. For more information about vi key maps, see the Nutshell Handbook Learning the vi Editor.)

For example, after you enter a field like To: fred, you can stay in text-input mode, press CTRL-N to move to the end of the next empty field (usually cc:), and be in text-input mode, ready to fill in the next address.