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

cw takes whitespace between words #9

Closed
oblitum opened this issue Apr 24, 2017 · 10 comments
Closed

cw takes whitespace between words #9

oblitum opened this issue Apr 24, 2017 · 10 comments

Comments

@oblitum
Copy link

oblitum commented Apr 24, 2017

Is it intentional to consume the whitespace between words? I'm getting myself frequently making mistakes because of this change, for example in |foo bar (cursor is |), I see that for dw it's indeed useful to delete whitespace, maybe, but for cw it doesn't make much sense, even more because it's inconsistent with ciw that whose purpose is to change word from inside the word, but it differs from behavior given that it doesn't consume whitespace, as in usual Vim.

@oblitum
Copy link
Author

oblitum commented Apr 24, 2017

Hmm, OK, now I got that the caveat section in the README is about this... I just don't understand why this was chosen...

@chaoren
Copy link
Owner

chaoren commented Apr 25, 2017

You want de (or ce) instead of dw (or cw). If you consider the actual motion of w (which is a totally different thing from iw), Vim is the inconsistent one here. If you prefer the original behavior just do this:

map dw de
map cw ce

Or just train yourself to use the correct e version.

@chaoren chaoren closed this as completed Apr 25, 2017
@oblitum
Copy link
Author

oblitum commented Apr 25, 2017

Ah, OK thanks :) I'll try to train that.

@oblitum
Copy link
Author

oblitum commented Apr 25, 2017

I suggest a mention of de and ce in README, as dw and cw is so popular... newbies may miss it in general.

@chaoren
Copy link
Owner

chaoren commented Apr 25, 2017

It is there:

"This plugin faithfully follows the motion of w, while Vim replaces these two special cases with the behavior of de and ce, respectively."

@oblitum
Copy link
Author

oblitum commented Apr 25, 2017

Ah, I didn't connect the dots because there was no reference to dw/cw, which is what I got used to.

@chaoren
Copy link
Owner

chaoren commented Apr 25, 2017

dw and cw is in the big diagram. Is it hard to read? I'll add dw and cw to the text then.

@oblitum
Copy link
Author

oblitum commented Apr 25, 2017

Well, there're references in the diagram above indeed... but I didn't connect ce was brother of cw because of the distance in text. Enough excuses huh? :)

chaoren added a commit that referenced this issue Apr 25, 2017
@chaoren chaoren added the invalid label Feb 8, 2018
@tmandry
Copy link

tmandry commented Mar 25, 2019

I also didn't realize from the README that I could just map dw and cw. Glad I found this issue. The mention of "special cases" made me think that it wasn't that simple, i.e. that vim was doing something more clever than this.

@chaoren
Copy link
Owner

chaoren commented Mar 25, 2019

https://github.com/vim/vim/blob/b45125b374cc3a1cef176b704f518c72c518f24c/runtime/doc/motion.txt#L413

Special case: "cw" and "cW" are treated like "ce" and "cE" if the cursor is
on a non-blank. This is because "cw" is interpreted as change-word, and a
word does not include the following white space. {Vi: "cw" when on a blank
followed by other blanks changes only the first blank; this is probably a
bug, because "dw" deletes all the blanks}

It really is just a special case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants