Better mechanism to choose the default editor (and avoid vi if possible)?

Scott Palmer swpalmer at gmail.com
Fri May 29 14:12:16 UTC 2020


+1

Scott

> On May 29, 2020, at 10:08 AM, PIERRE AUGIER <pierre.augier at univ-grenoble-alpes.fr> wrote:
> 
> From my experience, beginners are strongly disturbed when vi (or vim) is opened automatically (see https://stackoverflow.blog/2017/05/23/stack-overflow-helping-one-million-developers-exit-vim/).
> 
> For now, the default editor for Mercurial is vi. And to change the editor for one user, the dedicated Mercurial command (hg config --edit) opens... vi.
> 
> In https://www.mercurial-scm.org/wiki/editor, it is written:
> 
> "
> 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 
> 
> On Windows, the installer places a configuration file inside %programfiles%\Mercurial\hgrc.d\ that contains the editor settings (notepad by default). Thus, if you want to override it, you either have to redefine the configuration option or use an HGEDITOR environment variable (VISUAL and EDITOR will be ignored). 
> "
> 
> I think it is not a great design.
> 
> - Default is vi, which is a poor choice for many users. 
> - A particular mechanism for Windows, so that standard environment variables are not considered (VISUAL and EDITOR).
> - It assumes that "the installer" does something particular for Windows, which is not granted (there are different ways to install Mercurial on Windows)
> 
> Instead, Mercurial could do something like:
> 
> 5. nano (Unix) or notepad (Windows), if none of the above is set
> 6. vi, if previous editors are not available
> 
> Then, no need to have "editor = notepad" in %programfiles%\Mercurial\hgrc.d and VISUAL and EDITOR would be considered on Windows like with other OS.
> 
> Moreover, the default .hgrc content used by `hg config --edit` when there is no ~/.hgrc file could contain "editor = the-choosen-editor" so it would be very easy and intuitive for all users to change their editor, for example to change "nano" to "vi" for vi users on Unix if nano is installed.
> 
> Do you think Mercurial could be changed in this direction? What would be the drawback of this choice?
> 
> Pierre



More information about the Mercurial mailing list