How can I use vim not vi to write commit message?
When I do hg commit, it use vi as my default editor, how to change i开发者_高级运维t to vim?
From the editor docs:
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"
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 <Bob.Jones@gmail.com>
editor=nano
Pretty simple
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, with the most common being definition of different environmental variables like HGEDITOR
, VISUAL
, or EDITOR
.
精彩评论