开发者

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

开发者 https://www.devze.com 2023-01-20 18:14 出处:网络
When I do hg commit, it use vi as my default editor, how to change i开发者_高级运维t to vim?From the editor docs:

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):

  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"


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消