Consider using a default editor for the `ViEditVisually` function and / or issue a warning if the `$env:VISUAL` / `$env:EDITOR` value is invalid.

Open
#4,004 1 comment 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
38/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
csharp
Domain
cli

Research direction

Start by tracing the ViEditVisually function and how it resolves $env:VISUAL and $env:EDITOR. Define behavior for missing or invalid values, including platform-specific default editors and synchronous Windows invocation; done means users receive feedback instead of only a beep and the chosen editor behavior is covered by relevant tests.

Written by the indexing model from the issue text.

Description

Issue-Enhancement Needs-Triage :mag:
Prerequisites
  • Write a descriptive title.
Description of the new feature/enhancement

Currently, invoking the ViEditVisually function fails with no feedback other than a beep:

Consider modifying the behavior as follows, which would not only be more user-friendly in general, but also align with the behavior of other utilities, such as bash and git:

  • Use a default editor if neither $env:VISUAL no $env:EDITOR are defined - and issue a warning if it cannot be found.

    • A possible candidate on Unix-like platform is vi (this is what git does, though on some platforms it has gedit as the compiled-in default)
    • On Windows, Notepad would do as a guaranteed-to-be-present option, though that would require invocation via Start-Process -Wait (or equivalent) to ensure synchronous execution. Note that if a given machine has Git for Windows installed, nano and vim are present (but not in $env:PATH), via $env:ProgramFiles\Git\usr\bin\nano.exe and $env:ProgramFiles\Git\usr\bin\vim.exe
  • Issue a warning if the effective $env:VISUAL / $env:EDITOR value isn't valid; ditto, should the decision be made not to implement use of a default editor and neither $env:VISUAL nor $env:EDITOR is defined.

Proposed technical implementation details (optional)

No response

Dominant language
C#
Stars
4.4k
Forks
341
PR merge metrics
No merged PRs in 30d

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from PowerShell/PSReadLine

All issues in PowerShell/PSReadLine

Similar issues

More C# issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.