Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow :x on empty Helix #4087

Open
m13253 opened this issue Oct 3, 2022 · 1 comment
Open

Allow :x on empty Helix #4087

m13253 opened this issue Oct 3, 2022 · 1 comment
Labels
A-helix-term Area: Helix term improvements C-enhancement Category: Improvements

Comments

@m13253
Copy link

m13253 commented Oct 3, 2022

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.

@m13253 m13253 added the C-enhancement Category: Improvements label Oct 3, 2022
@kirawi kirawi added the A-helix-term Area: Helix term improvements label Oct 3, 2022
@raygervais
Copy link
Contributor

I'd like to take a crack at this, it's a small quality of life improvement that I believe will also help my understanding of learning Rust in the perspective of a grand project

williamporomaa added a commit to williamporomaa/helixstuff that referenced this issue Oct 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-helix-term Area: Helix term improvements C-enhancement Category: Improvements
Projects
None yet
Development

No branches or pull requests

3 participants