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

yW (yank WORD) not working properly in normal mode #1448

Closed
ferdinandyb opened this issue Feb 1, 2024 · 7 comments · Fixed by #1555
Closed

yW (yank WORD) not working properly in normal mode #1448

ferdinandyb opened this issue Feb 1, 2024 · 7 comments · Fixed by #1555
Labels
enhancement New feature or request vi-mode Vi/Vim movement and operation mode

Comments

@ferdinandyb
Copy link
Contributor

Contour Terminal version

Contour Terminal Emulator 0.4.2.6408-prerelease

Installer source

Github: CI actions

Operating System

Windows 11

Architecture

x86-64

Other Software

No response

Steps to reproduce

Run something like echo "hello 1236", enter normal mode, search for hello and then yank WORD with yW.

Expected Behavior

I would expect "hello" to be yanked.

Actual Behavior

"hello 1" is yanked

Additional notes

No response

@ferdinandyb ferdinandyb added the bug Something isn't working label Feb 1, 2024
@christianparpart christianparpart added the vi-mode Vi/Vim movement and operation mode label Feb 2, 2024
@christianparpart
Copy link
Member

@ferdinandyb I think there's a misunderstanding.

  • w refers to the beginning of the next word (using word delimiters, such as ., ,, :, space, etc..
  • W refers to the beginning of the next word (using whitespace delimiters only)
  • e refers to the end of the current word (delimiters as in w)
  • W refers to the end of the current word (delimiters as in W, i.e. whitespaces only)

So pressing yW will yank everything from the current cursor position to the beginning of the next word whereas yE (and similarily ye) will yank from current position to the end of the current word.

p.s.: I was implementing this based on what I was reading in the vim documentation. However, trying it out right now in vim (and Contour), I noticed a different in vim itself.

vim itself behaves differently in marking the range for yW vs vW. This is a WTF for me. I may have accidentally skipped reading something in the docs that would describe this, but to me that sounds a bit weird. Not sure sure why yW and vW in vim (neovim for me) do operate on a different range, that is, yW excludes the right boundary whereas vW does indeed include it (as we do in Contour, however, for both cases).

So not sure how to process on this ticket. If vim and neovim are doing it that way, then we should adapt of course. Because it's meant to be inspired by vim. It should feel the same then.

@ferdinandyb
Copy link
Contributor Author

ferdinandyb commented Feb 2, 2024 via email

@christianparpart
Copy link
Member

Keep me posted, please. :)

@ferdinandyb
Copy link
Contributor Author

ferdinandyb commented Feb 2, 2024 via email

@Yaraslaut
Copy link
Member

Yaraslaut commented Feb 3, 2024

vim itself behaves differently in marking the range for yW vs vW.

evil-mode behaves similar to contour, makes selection until the next word

@ferdinandyb
Copy link
Contributor Author

The vim question is still ongoing, but two comments came to mind:

  • yanking the first character of the next WORD is a bug either way: neither yW nor vW does that

  • the exact amount of whitespace yanked could be totally irrelevant in many cases, especially if there's a white space stripping mechanism (which I sort of remember contour having?)

@ferdinandyb
Copy link
Contributor Author

Here's the detailed answer: https://vi.stackexchange.com/a/44056/25312. In short:

  • motions can be inclusive or exclusive, but that only counts after an operator, not when using them to move the cursor in normal mode

  • visual mode always implies inclusive unless the defaults are changed

I guess the question is, how close you want to copy vim. I personally think, it should be as close to vim defaults as possible, but that does entail some additional complexity right now.

@Yaraslaut Yaraslaut added enhancement New feature or request and removed bug Something isn't working labels Feb 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request vi-mode Vi/Vim movement and operation mode
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants