zed-industries / zed

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
https://zed.dev
Other
45.71k stars 2.52k forks source link

Uppercase Vim Commands Not Functioning Properly in Normal Mode #7512

Open nnamdiogbu opened 6 months ago

nnamdiogbu commented 6 months ago

Check for existing issues

Describe the feature

In the current implementation of the Vim mode in the text editor, I've encountered several issues with uppercase Vim commands not functioning as expected while in normal mode. Below are the specific observations:

  1. Uppercase "O" Behavior:

    • Expected Behavior: When in normal mode, pressing uppercase "O" should create a new line above the current line, move the cursor to this new line, and switch to insert mode.
    • Actual Behavior: Pressing uppercase "O" behaves similarly to pressing lowercase "o", creating a new line below the current line, moving the cursor to this new line, and switching to insert mode. This behavior deviates from the standard Vim behavior.
  2. Uppercase Vim Commands:

    • Expected Behavior: Uppercase Vim commands, such as uppercase "V" for linewise visual mode, should perform their respective actions as defined in the Vim documentation.
    • Actual Behavior: None of the uppercase Vim commands seem to be functioning. For instance, pressing uppercase "V" does not activate linewise visual mode, and other uppercase commands also do not yield expected results.
  3. Additional Observations:

    • I also noticed that the combinations "g+e", "g+~" and others don't seem to work as expected. These commands are essential for certain text manipulation tasks and their absence limits the functionality of the Vim mode in the editor.

Vim mode is kind of unusable right now

If applicable, add mockups / screenshots to help present your vision of the feature

No response

ConradIrwin commented 6 months ago

Hi @nnamdiogbu! Thanks for this issue.

I am surprised that O and V are not working, they definitely should! What keyboard layout are you using? Do you have any custom keybindings defined?

Even once we fix that, not everything is there (yet!):

If you'd like to pair with me on g~ (or just debugging why O and V don't work for you), please book time: https://calendly.com/conradirwin/pairing

nnamdiogbu commented 6 months ago

Hi @ConradIrwin

I use the ANSI keyboard layout. No, I do not have any custom keybindings.

nnamdiogbu commented 6 months ago

Regarding O and V, they only work when used with the shift key. I had previously been using caps lock, and that was why it didn't work.

Since caps lock is not a modifier key, I cannot simply bind it to ToggleVisualBlock in assets/keymaps/vim.json. Is there some other way to perform this binding?

ConradIrwin commented 6 months ago

@nnamdiogbu I see! Currently we ignore the caps-lock key for the purposes of this.

You should be able to make this work by adding bindings to the upper-case versions of the keys to your keybindings. (You can see all vim bindings here).

{
  "context":  "vim_mode == normal && vim_operator == none && !VimWaiting"
  "bindings": {
    "O": "vim::InsertLineAbove",
// ... etc.
  }
}

Is there a reason you use caps-lock instead of shift?

0x2CA commented 6 months ago

@nnamdiogbu I see! Currently we ignore the caps-lock key for the purposes of this.

You should be able to make this work by adding bindings to the upper-case versions of the keys to your keybindings. (You can see all vim bindings here).

{
  "context":  "vim_mode == normal && vim_operator == none && !VimWaiting"
  "bindings": {
    "O": "vim::InsertLineAbove",
// ... etc.
  }
}

Is there a reason you use caps-lock instead of shift?

This is a matter of habit, usually more commonly used lowercase letters, the temporary need for uppercase letters using shift, but it is true that people use caps to open the lock, cancel the lock after the input is complete!

AquilaFasciata commented 1 month ago

I wanted to add that some IME software and Virtual Keyboards on Linux may affect this as well. I use IBus Wayland with KDE and this combo appears to break uppercase commands. Switching off the virtual input causes it to respond as expected.