When I do hg commit, it use vi as my default editor, how to change it to vim?
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.
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.
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 <[email protected]> editor=nano
Pretty simple
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With