diff --git a/doc.go b/doc.go index b5ed9099..1e44629f 100644 --- a/doc.go +++ b/doc.go @@ -180,6 +180,7 @@ The following environment variables are exported for shell commands: OLDPWD LF_LEVEL OPENER + VISUAL EDITOR PAGER SHELL @@ -940,7 +941,7 @@ If this variable is set in the environment, use the same value. Otherwise, this EDITOR -If this variable is set in the environment, use the same value. Otherwise, this is set to 'vi' on Unix, 'notepad' in Windows. +If VISUAL is set in the environment, use its value. Otherwise, use the value of the environment variable EDITOR. If neither variable is set, this is set to 'vi' on Unix, 'notepad' in Windows. PAGER diff --git a/docstring.go b/docstring.go index 4d09f6e2..ef416d90 100644 --- a/docstring.go +++ b/docstring.go @@ -183,6 +183,7 @@ The following environment variables are exported for shell commands: OLDPWD LF_LEVEL OPENER + VISUAL EDITOR PAGER SHELL @@ -1005,8 +1006,9 @@ this is set to 'start' in Windows, 'open' in MacOS, 'xdg-open' in others. EDITOR -If this variable is set in the environment, use the same value. Otherwise, -this is set to 'vi' on Unix, 'notepad' in Windows. +If VISUAL is set in the environment, use its value. Otherwise, use the value of +the environment variable EDITOR. If neither variable is set, this is set to 'vi' +on Unix, 'notepad' in Windows. PAGER diff --git a/lf.1 b/lf.1 index b6ec295b..a0a2c451 100644 --- a/lf.1 +++ b/lf.1 @@ -201,6 +201,7 @@ The following environment variables are exported for shell commands: OLDPWD LF_LEVEL OPENER + VISUAL EDITOR PAGER SHELL @@ -1138,7 +1139,7 @@ If this variable is set in the environment, use the same value. Otherwise, this EDITOR .EE .PP -If this variable is set in the environment, use the same value. Otherwise, this is set to 'vi' on Unix, 'notepad' in Windows. +If VISUAL is set in the environment, use its value. Otherwise, use the value of the environment variable EDITOR. If neither variable is set, this is set to 'vi' on Unix, 'notepad' in Windows. .PP .EX PAGER diff --git a/os.go b/os.go index 75f6ea9f..a0ae9fda 100644 --- a/os.go +++ b/os.go @@ -18,7 +18,7 @@ import ( var ( envOpener = os.Getenv("OPENER") - envEditor = os.Getenv("EDITOR") + envEditor = os.Getenv("VISUAL") envPager = os.Getenv("PAGER") envShell = os.Getenv("SHELL") ) @@ -51,7 +51,10 @@ func init() { } if envEditor == "" { - envEditor = "vi" + envEditor = os.Getenv("EDITOR") + if envEditor == "" { + envEditor = "vi" + } } if envPager == "" { diff --git a/os_windows.go b/os_windows.go index 4c635fa5..2dca3376 100644 --- a/os_windows.go +++ b/os_windows.go @@ -14,7 +14,7 @@ import ( var ( envOpener = os.Getenv("OPENER") - envEditor = os.Getenv("EDITOR") + envEditor = os.Getenv("VISUAL") envPager = os.Getenv("PAGER") envShell = os.Getenv("SHELL") ) @@ -45,7 +45,10 @@ func init() { } if envEditor == "" { - envEditor = "notepad" + envEditor = os.Getenv("EDITOR") + if envEditor == "" { + envEditor = "notepad" + } } if envPager == "" {