How can I use vim not vi to write commit message?

14,715

Solution 1

From the editor docs:

Mercurial tries to pick which program to call to edit a commit message by trying the following (in order):

  1. HGEDITOR environment variable
  2. editor configuration option in [ui] section (in hgrc or passed with --config ui.editor command-line option).
  3. VISUAL environment variable
  4. EDITOR environment variable
  5. vi, if none of the above is set

Personally I prefer to just do hg commit -m "My commit message"

Solution 2

Find your .hgrc file in your home directory and add the following line:

editor=vim

That should do it.

So let's say you use nano for cases like this. Your .hgrc file would read something like:

[ui]
username = Bob Jones <[email protected]>
editor=nano

Pretty simple

Solution 3

Probably set the EDITOR environment variable: EDITOR=vim

Whenever you hg commit, mercurial will create a file like /tmp/hg-editor-mX1MbE.txt and invoke $EDITOR on it. Because the file already has contents, many editors will create a backup file /tmp/hg-editor-mX1MbE.txt~ or similar. The actual temp file hg wants to use (/tmp/hg-editor-mX1MbE.txt) is later removed, but the backup files stay around.

(source : debian bug reports

Solution 4

List of ways to do it, with the most common being definition of different environmental variables like HGEDITOR, VISUAL, or EDITOR.

Share:
14,715
guilin 桂林
Author by

guilin 桂林

Python and web

Updated on June 17, 2022

Comments

  • guilin 桂林
    guilin 桂林 about 2 years

    When I do hg commit, it use vi as my default editor, how to change it to vim?