4 ms·
Just like any other sort-of-Vim implementation, cw (change word) is made to be consistent with dw (delete word), and Y (yank line) is made to be consistent with
by rav 6y ago
Just like any other sort-of-Vim implementation, cw (change word) is made to be consistent with dw (delete word), and Y (yank line) is made to be consistent with D (delete line). In classic vi, these commands are illogical in that cw doesn't eat the space following the word like dw does, and Y works on the entire line, whereas D deletes only from the cursor to the end of the line. The Vim manual states that:
If you like "Y" to work from the cursor to the end of line (which is more logical, but not Vi-compatible) use ":map Y y$".
...however, I'm used do cw and Y being illogical like that, goshdarnit, so when these Vim-clones come along and "fix" it, I'm thrown off at every step I take.
- v-yadli 6y agoI usually think of cw vs. dw as changing the data in a node vs. removing a node (together with its next pointer), in a linked list.
- darrenf 6y agoI’ve never found the cw/dw case illogical. When I’m deleting a “word” (in prose or code) it’s rarely, perhaps never, my intention to leave a double space between the surrounding words. But if I am changing one, the likelihood is that I’ll want to trailing space to remain after I type the replacement. So whilst I see nothing illogical, I’m in agreement that a change to these commands would throw me!
- ysavir 6y agoIt's practical, but it's not logically consistent with what's considered a "word" in Vim. "Delete word" and "Delete until next word" are two different functionalities, so there's an inconsistency when a function shortcut is named to represent the former, but behaves like the latter.
- wraithy 6y agoThere's always "ce" (change until end of word), which enables the common use case and is also consistent with the rest of the vim language. I wonder why the special case for "cw" exists... I'd love to hear the story about that initial decision.
- boogies 6y agoI'd guess just because cw is much easier/faster to type (because c and e are pressed with the same finger) on a QWERTY keyboard.
- mkl 6y agoNot if you're touch typing with any standard fingering I've seen. C is first finger, and E is middle finger.
- michaelcampbell 6y agoYou might need to look around more. The wikipedia article shows 'c' on the middle finger, like I was taught. I can't imagine doing it with the first finger, but I suppose it just depends on how you were taught. Looking around, I can't even FIND a "c on first finger" fingering. - https://en.wikipedia.org/wiki/Touch_typing#/media/File:FingerHandPosUSA.gif https://en.wikipedia.org/wiki/Touch_typing#/media/File:Finge... - http://www.typingme.com/touch-typing/typing-lesson-9.php http://www.typingme.com/touch-typing/typing-lesson-9.php - https://agilefingers.com/articles/touch-typing-finger-placement https://agilefingers.com/articles/touch-typing-finger-placem... - https://www.computerhope.com/issues/ch001346.htm https://www.computerhope.com/issues/ch001346.htm - https://www.ratatype.com/learn/ https://www.ratatype.com/learn/ and on and on.
- oogetyboogety 6y agoDidn't even realize I use index finger for c until you mentioned it. Turns out I should be using my E/middle finger. Hm.
- ybbond 6y agoI did watch me and my friends' touch typing behavior, and most of us use left index finger for RFCVGT(B), and right index finger for YUHJ(B)NM. the character in parenthesis means it overlaps between right and left area
- mkl 6y ago
- krick 6y agoI have absolutely no idea what people are talking about in this thread. I never noticed any of this, and even went right now to test it on Vim 8.0, and nothing of what you are saying seems to be correct. I have quite a big .vimrc, but I don't think I re-configured any of this. Maybe all of it applies only to vi, not vim?
- umanwizard 6y agoTry with `vim -u NONE` to ignore your .vimrc . If the buffer is “asdf jkl” with your cursor at the beginning of the line, after dw the buffer is “jkl”. With the same starting buffer, after cw, the buffer is “ jkl”, with a space at the beginning (which is the same behavior as ce). This “inconsistent” behavior is probably what you usually want, but it does indeed break the invariant that c<motion> is equivalent to d<motion>i .
- chrismorgan 6y ago> the invariant that c<motion> is equivalent to d<motion>i Nit: that invariant also doesn’t work when the motion takes you to the end of the line because of how the cursor is one character wide in normal mode and zero characters wide in insert mode. On a buffer “asdf jkl” with the cursor on the letter f, c$x gets you “asd|” (| representing the cursor location), whereas d$ix gets you “as|d”.
- timoth 6y agoInteresting. I never use Y or D, I use yy and dd which both operate on the entire line. I like that they're lower case and 'fit' in my mind with their other 2 character counterparts, yw, dw etc. (and I use d$ for delete to end of line).
- boogies 6y agoNot every sort-of-Vim implementation (ofc). I use vis¹, which has the classic cw, but the consistent Y. And I prefer it the vis way. cw is a binding I use often, and more pleasant to type than ce. yy I also use fairly frequently, but Y is not much more pleasant, and y$ is much less pleasant, and I copy from the cursor to the line end often enough to want it to be easy, quick, and feel nice. ¹: https://sr.ht/martanne/vis/ https://sr.ht/martanne/vis/