c command

58 views
Skip to first unread message

Marcin Szamotulski

unread,
Apr 11, 2012, 6:54:55 AM4/11/12
to Vim Dev
Hello,

It seems for me that cw and ce commands works the same while dw and de and
other operator like commands have a different behaviour. I did testing with
"vim -u NONE" (I also use the default 'cpo').

How to reproduce:

put the cursor at the beginning of word1 and try both cw and ce normal
commands:

word1 word2


In both cases the space between word1 and word2 is not deleted, while I expect
that cw would make the change up to word3.

Best regards,
Marcin Szamotulski

Christian Brabandt

unread,
Apr 11, 2012, 9:38:46 AM4/11/12
to vim...@googlegroups.com

I think that is a strange historic Vi behaviour that is required by POSIX
nowadays. We could possibly add another flag to 'cpo' to work around it,
but my feeling is that too many people are accustomed to the way it works
currently that it isn't worth the trouble. (We already have the 'w' flag
for another strange behaviour when using the c motion on blanks)

regards,
Christian

Ben Fritz

unread,
Apr 11, 2012, 10:26:06 AM4/11/12
to vim...@googlegroups.com

From the help:

> *cw* *cW*
> Special case: When the cursor is in a word, "cw" and "cW" do not include the
> white space after a word, they only change up to the end of the word. This is
> because Vim interprets "cw" 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; use the
> 'w' flag in 'cpoptions' to make it work like Vi anyway}
>
> If you prefer "cw" to include the space after a word, use this mapping: >
> :map cw dwi
> Or use "caw" (see |aw|).

Marcin Szamotulski

unread,
Apr 11, 2012, 11:09:51 AM4/11/12
to vim...@googlegroups.com
> --
> You received this message from the "vim_dev" maillist.
> Do not top-post! Type your reply below the text you are replying to.
> For more information, visit http://www.vim.org/maillist.php

Great. I don't think adding another cpo flag is necessary as ":help cw" also
suggest a nice solution:
map cw dwi
or to use "caw" command.

Thanks!
Marcin

Reply all
Reply to author
Forward
0 new messages