Skip to content

Allow :x on empty Helix #4087

@m13253

Description

@m13253

Related issue:
About mapping ZZ to :x: #2041 (comment)

Steps to reproduce:

  1. Use the keybind config:
    [keys.normal]
    Z = { Q = ":quit!", Z = ":x" }
  2. Open an empty Helix:
    $ hx
  3. Type ZZ to quit.

What to expect:
Helix should exit.

What to observe:
Error message: cannot write a buffer without a filename

Workaround
In Vim, a similar keybinding is called ZQ, which triggers :quit!.
You can use ZQ in this situation.

Why ZZ doesn't work in Helix?
There is a difference in Helix's :x command comparing with Vim's.
In Vim:

  • :wq means save and quit, no matter the file has been modified or not.
  • :x (:xit) means if the file has been modified, save and quit, otherwise directly quit.
  • For an empty unnamed buffer, :x works without a filename, while :wq doesn't.

However in Helix:

  • :x is an alias to :wq.
  • Both save and quit, even with no changes or with external changes.
  • For an empty unnamed buffer, both don't work without a filename.

Proposed solutions
Make :x different from :wq.
Besides the benefit of being able to :x an empty unnamed buffer, the original behavior of :x is important when the file is changed from another application: You usually don't want to overwrite that change.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-helix-termArea: Helix term improvementsC-enhancementCategory: Improvements

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions