Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

mercurial

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

like image 948
guilin 桂林 Avatar asked Oct 20 '10 06:10

guilin 桂林


People also ask

What is the command you can use to write a commit message?

The easiest way to create a Git commit with a message is to execute “git commit” with the “-m” option followed by your commit message.

What is vim command in git?

Vim is a very useful and helpful editor for creating and editing different types of files more efficiently. Many new features are added in this editor that makes it a powerful editor. Many plugins are developed by many coders for this editor to increase and configure its core functionalities.


2 Answers

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"

like image 135
Paolo Avatar answered Sep 17 '22 16:09

Paolo


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

like image 33
clay Avatar answered Sep 20 '22 16:09

clay