Editor command helper should look for `VISUAL` env var before `EDITOR`

The Rails::Command::Helpers::Editor module, used by the credentials, encrypted, and secrets commands to open a temporary file for editing in the user’s preferred editor, currently only uses the EDITOR environment variable to know which command to run to open that editor. I believe it should also use the VISUAL environment variable, and it should prefer it over EDITOR.

See this StackExchange answer for some context:

The EDITOR editor should be able to work without use of “advanced” terminal functionality (like old ed or ex mode of vi). It was used on teletype terminals.

A VISUAL editor could be a full screen editor as vi or emacs.

E.g. if you invoke an editor through bash (using C-x C-e), bash will try first VISUAL editor and then, if VISUAL fails (because terminal does not support a full-screen editor), it tries EDITOR.

Nowadays, you can leave EDITOR unset or set it to vi -e.

I’m happy to submit a PR for this if others are okay with it!

Hey Summer, I think this change makes sense. Please go ahead with the PR

1 Like

PR #48374 submitted. :slightly_smiling_face:

1 Like