When I do hg commit, it use vi as my default editor, how to change it to vim?
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
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
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):
- HGEDITOR environment variable
- editor configuration option in [ui] section (in hgrc or passed with --config ui.editor command-line option).
- VISUAL environment variable
- EDITOR environment variable
- vi, if none of the above is set
Personally I prefer to just do hg commit -m "My commit message"