gitcommand-line

How do you use "ed" as the editor for the "git" command line?


I want set core.editor in git so that the editor used is ed. How do I do that?

(The reason is that I don't like having to switch to another window just to write commit messages and rebase scripts. I also don't like the way vim takes up the whole terminal screen, preventing me from scrolling back to my command history while I'm editing)


Solution

  • In your .git.config file, add:

    [core]
        editor = /path/to/ed.exe -v -p'> ' -l
    

    The -v option turns on ed error messages, so you will get more than just ? for errors (this is optional).

    The -p option adds a prompt (of >) to ed so you can tell the difference between command and input mode (this is optional).

    The -l option is necessary to ensure that exiting the editor always returns a 0 exit code back to git, since ed normally returns a non-zero exit code if you make any errors while editing, even if you later correct them. (Returning a non-zero exit code back to git would cause whatever operation launched the editor to fail)

    Using ed from git