contour
contour copied to clipboard
yW (yank WORD) not working properly in normal mode
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 I think there's a misunderstanding.
wrefers to the beginning of the next word (using word delimiters, such as.,,,:, space, etc..Wrefers to the beginning of the next word (using whitespace delimiters only)erefers to the end of the current word (delimiters as inw)Wrefers to the end of the current word (delimiters as inW, 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 I think there's a misunderstanding.
wrefers to the beginning of the next word (using word delimiters, such as.,,,:, space, etc..Wrefers to the beginning of the next word (using whitespace delimiters only)erefers to the end of the current word (delimiters as inw)Wrefers to the end of the current word (delimiters as inW, i.e. whitespaces only)So pressing
yWwill yank everything from the current cursor position to the beginning of the next word whereasyE(and similarilyye) 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
yWvsvW. 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 whyyWandvWin vim (neovim for me) do operate on a different range, that is,yWexcludes the right boundary whereasvWdoes 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.
Ok, so I agree, this is rather confusing ... I did a little search and found this:
https://vi.stackexchange.com/a/24731/25312:
In Vim motions can be either inclusive ("include the rightmost character"), or exclusive ("exclude rightmost character"). w is made exclusive (so you delete exactly four words: "this" "is" "a" "test"). If you want to make it inclusive add :h o_v to the target command: d4vw.
Now, in Visual mode all motions are governed by a global option called :h 'selection'. By default, it's :set selection=inclusive, so ! gets into the visual selection. Add :set selection=exclusive to your vimrc if you don't like it.
I must say, I am a bit confused now, because also W moves to next WORD, but yW yank until the end of the current WORD. I'm confused enough to make a question on stackexchange: https://vi.stackexchange.com/q/44054/25312.
In general I'd say it's best if contour does "default vim", but I would probably like to understand this a bit better now before I say anything :D
Keep me posted, please. :)
will do :)
vim itself behaves differently in marking the range for
yWvsvW.
evil-mode behaves similar to contour, makes selection until the next word
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
yWnorvWdoes 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?)
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.