Skip to content

**/editor command fails when VISUAL contains arguments with spaces/quotes** #7749

Closed as not planned

Description

@ragu-manjegowda

Description

Problem

The /editor command fails when the VISUAL environment variable contains command-line arguments with spaces or quotes. The arguments are incorrectly split, causing nvim to misinterpret them.

Environment

  • OS: Arch Linux (BTW)
  • OpenCode version: 1.0.220 (installed via Homebrew)
  • Shell: zsh

Steps to Reproduce

  1. Set VISUAL with arguments:

    export VISUAL="nvim --cmd 'let g:flatten_wait=1'"
  2. Start OpenCode TUI:

    opencode
  3. Run /editor command

Expected Behavior

Nvim opens with the --cmd 'let g:flatten_wait=1' argument properly passed, allowing the g:flatten_wait variable to be set before rc loads.

Actual Behavior

Error appears:

Error detected while processing pre-vimrc command line:
E20: Mark not set: 'let
Already only one window

Root Cause

The VISUAL variable appears to be split on spaces without proper quote handling. Instead of:

nvim --cmd 'let g:flatten_wait=1' /tmp/opencode-xxxxx

It's likely being invoked as:

nvim --cmd 'let g:flatten_wait=1' /tmp/opencode-xxxxx
       ↑
       Split here, so vim sees: --cmd "'let" "g:flatten_wait=1'"

Vim interprets 'let as a mark reference (marks start with '), hence E20: Mark not set.

Use Case

This pattern (VISUAL with --cmd or other flags) is common for:

  • flatten.nvim users who need let g:flatten_wait=1 for nested terminal support

Suggested Fix

Consider one of these approaches:

Use eval to properly handle quoted arguments:

// Instead of splitting on spaces
cmd := exec.Command("sh", "-c", editor + " " + shellescape(filepath))

Related

This is a common issue in CLI tools. Similar fixes have been implemented in:

  • ranger (uses eval ${VISUAL:-$EDITOR} -- "$@")
  • git (supports core.editor with proper argument handling)

Plugins

No response

OpenCode version

1.0.220

Steps to reproduce

export VISUAL="nvim --cmd 'let g:flatten_wait=1'"

Screenshot and/or share link

Image

Operating System

Arch Linux

Terminal

Alacritty

Activity

  1. github-actions commented on Mar 25, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 90 days of no activity. If the issue is still relevant please open a new one.

  2. removed
    bugSomething isn't working
    on May 3, 2026
  3. mawkler commented on May 20, 2026

    @mawkler

    I have the same issue but for the $EDITOR system variable

  4. mawkler commented on Aug 3, 2026

    @mawkler

    It would be super appreciated if you could elaborate on why this was closed as "not planned" since this to me is an obvious bug :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions