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

Repeating indent doesn't select the same portion of text in Vim mode #12351

Closed
1 task done
janko opened this issue May 27, 2024 · 7 comments
Closed
1 task done

Repeating indent doesn't select the same portion of text in Vim mode #12351

janko opened this issue May 27, 2024 · 7 comments
Labels
defect [core label] editor Feedback for code editing, formatting, editor iterations, etc vim

Comments

@janko
Copy link

janko commented May 27, 2024

Check for existing issues

  • Completed

Describe the bug / provide steps to reproduce it

In Vim, when I select a portion of text in visual line mode and press </>, I then often use "." to repeat the indent/outdent on the same text multiple times. E.g. in Ruby if I want to outdent by 4 spaces, I would press < (2 spaces) and then . once (2 more spaces).

In Zed, this doesn't appear to work correctly. When I hit . after </>, it indents/outdents a different part of text than what I initially selected.

I would be fine with indenting with Tab and outdenting Shift-Tab, but those don't appear to work in Vim's virtual line mode. It would be nice if it did 🙂

Environment

Zed: v0.136.2 (Zed)
OS: macOS 14.4.1
Memory: 8 GiB
Architecture: aarch64

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

Here I pressed < and then ....

Screen.Recording.2024-05-27.at.14.30.24.mov

If applicable, attach your ~/Library/Logs/Zed/Zed.log file to this issue.

No response

@janko janko added admin read Pending admin review defect [core label] triage Maintainer needs to classify the issue labels May 27, 2024
@Moshyfawn Moshyfawn added vim editor Feedback for code editing, formatting, editor iterations, etc and removed triage Maintainer needs to classify the issue labels May 27, 2024
@JosephTLyons JosephTLyons removed the admin read Pending admin review label May 28, 2024
@MaxThom

This comment was marked as spam.

@chrisvander
Copy link

Good workaround for now would be to use cmd { and cmd } for indenting/un-indenting, which I just discovered while trying to figure out why 4< didn't work.

@Thomascountz
Copy link

Thomascountz commented Jun 6, 2024

Edit: Due to lack of sleep, I didn't see #12582 was already open with a proposed solution. Ignore my notes below. Sorry!

Good workaround for now would be to use cmd { and cmd } for indenting/un-indenting, which I just discovered while trying to figure out why 4< didn't work.

⌘ + } and ⌘ + { will outdent and indent visual-selected lines, similar to > and <. However, they're not repeated when using the repeat command (.). I think it's because they are editor commands as opposed to vim commands.

I think the problem is that in visual mode, the vim command for > and < is only outdent/indent. But once in normal mode, when the repeat command is used (.), the command is first vim::PushOperator, and then outdent/indent. I'm thinking that the vim::PushOperator causes the cursor to first move, and then the outdent/indent happens.

Here is the relevant section of the default vim keymap:

[
  {
    "context": "Editor && vim_mode == visual && !VimWaiting && !VimObject",
    "bindings": {
        ">": "vim::Indent",
        "<": "vim::Outdent",
    }
  },
  {
    "context": "Editor && vim_mode == normal && vim_operator == none && !VimWaiting",
    "bindings": {
      ".": "vim::Repeat",
      ">": ["vim::PushOperator", "Indent"],
      "<": ["vim::PushOperator", "Outdent"],
    }
  }
]

I've tried changing my custom keymaps, but I still encounter the same behavior.

[
  {
    "context": "Editor && vim_mode == normal && vim_operator == none && !VimWaiting",
    "bindings": {
      ".": "vim::Repeat",
      ">": ["Indent"],
      "<": ["Outdent"]
    }
  }
]

mrnugget pushed a commit that referenced this issue Jun 6, 2024
Release Notes:

- vim: Fix indent via `<` and `>` not being repeatable with `.`.
[#12351](#12351)
@Moshyfawn
Copy link
Member

Please let us know if the attached PR has resolved the issue for you.

@Moshyfawn Moshyfawn added the needs info / awaiting response Issue that needs more information from the user label Jun 8, 2024
@janko
Copy link
Author

janko commented Jun 8, 2024

@Moshyfawn Would that require building Zed from source? I tried the latest preview now (0.139.3), but the behavior of repeating </> still appears to be the same.

@mrnugget
Copy link
Member

Yeah, the commit 2f05778 is not in a release yet. Will go into next Preview release on Wednesday. Stable the week after.

@JosephTLyons
Copy link
Contributor

The feature is now in today's preview (0.140-pre). I'm going to optimistically close this out, but feel free to ping us to reopen if something isn't correct.

ming900518 pushed a commit to ming900518/zed that referenced this issue Jun 14, 2024
…stries#12582)

Release Notes:

- vim: Fix indent via `<` and `>` not being repeatable with `.`.
[zed-industries#12351](zed-industries#12351)
@notpeter notpeter removed the needs info / awaiting response Issue that needs more information from the user label Jun 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
defect [core label] editor Feedback for code editing, formatting, editor iterations, etc vim
Projects
None yet
Development

No branches or pull requests

8 participants