tags:

views:

60

answers:

3

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

+2  A: 

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

Benoit
+1  A: 

List of ways to do it: http://mercurial.selenic.com/wiki/editor, with the most common being definition of different environmental variables like HGEDITOR, VISUAL, or EDITOR

birryree
+6  A: 

From the docs: http://mercurial.selenic.com/wiki/editor

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"

Paolo
+1. I'd go with [ui] in hgrc. -m will of course always work, no matter what editor you configured.
Thilo