-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
[Bug]w in cw is same as ce #4390
Comments
This is documented (under
|
Thanks. You got a wide range of knowledge. but since Or, can we exchange |
It's actually a strange vi behaviour: https://github.com/vim/vim/blob/master/src/normal.c#L8648-L8656 Some time ago I made a patch (and I think Neovim merged that one: |
I wonder is there a flag that I can easily turn on from different platforms to use corrected version of vim while we can keep default in old vim for compatibility?Why should we keep the garbage in the vim and carry on? |
There is a 'compatible' boolean option, and also a related set-of-one-letter-flags 'cpoptions' option, which allow disabling those legacy-vi established behaviours which Bram regards as bugs. 'compatible' is nowadays usually off except if you invoke Vim as 'vi' or with the -C command-line switch. But in general, Bram regards backward compatibility as extremely important, and IMHO rightly so: backward compatibility goes hand in hand with the principle of least surprise, or IOW, an application cannot be relied on if you cannot count on using it tomorrow like you used it yesterday. |
Thanks your kindness. I learned a lot
I checked As we know that Thanks again, you guys help me so much information. |
Hi there, again. Since I think compatibility do matters, but self-renewing ability also matters. Softwares should work as compatibility pattern by default while give a possibility for users to turn on all better and consistent features. Anyway keep a garbage is reasonable due to lacking of time or money or historical issues, but how can we reject growing? |
@chrisbra can you merge a version of your I've seen several workarounds, like this one, including the suggested mapping in the help docs, but none work like native support would. The help suggestion can only be multiplied like |
Alright, let me create a new PR for this one then. It needs a test and I must check how if this still applies. |
Problem: d{motion} may work different than expected (also cw is special cased by POSIX) Solution: add new cpo-z flag to make the behaviour configurable There are two special vi compatible behaviours: 1): cw behaves differently than dw. That is, because cw is special cased by Vim and is effectively aliased to ce. POSIX behaviour: https://pubs.opengroup.org/onlinepubs/9699919799/utilities/vi.html#tag_20_152_13_81 2): d{motion} may make the whole delete operation linewise, if the start and end of the motion are on different lines and there are only blanks before the start and after the end of the motion. Did not find a related POSIX link that requires this behaviour. Both behaviours can be considered inconsistent, but we cannot easily change it, because it would be a backward incompatible change and also incompatible to how classic vi behaved. So let's add the new cpo flag "w", which when not included fixes both behaviours and make them more consistent to what users would expect. This has been requested several times: https://groups.google.com/d/msg/vim_use/aaBqT6ECkA4/ALf4odKzEDgJ https://groups.google.com/d/msg/vim_dev/Dpn3xtUF16I/T6JcOPKN6usJ http://www.reddit.com/r/vim/comments/26nut8/why_does_cw_work_like_ce/ https://groups.google.com/d/msg/vim_use/vunNWLFWfQg/MmJh_ZGaAgAJ vim#4390 So in summary, if you want to have the w motion work more consistent, remove the 'z' from the cpo settings. related: vim#4390 Signed-off-by: Christian Brabandt <cb@256bit.org>
I made #15263 but Note: change change to |
Much appreciated, @chrisbra. |
Problem: d{motion} may work differently than expected (also cw is special cased by POSIX) Solution: add new cpo-z flag to make the behaviour configurable There are two special vi compatible behaviours: 1): cw behaves differently than dw. That is, because cw is special cased by Vim and is effectively aliased to ce. POSIX behaviour is documented here: https://pubs.opengroup.org/onlinepubs/9699919799/utilities/vi.html#tag_20_152_13_81 2): d{motion} may make the whole delete operation linewise, if the start and end of the motion are on different lines and there are only blanks before the start and after the end of the motion. Did not find a related POSIX link that requires this behaviour. Both behaviours can be considered inconsistent, but we cannot easily change it, because it would be a backward incompatible change and also incompatible to how classic vi behaved. So let's add the new cpo flag "z", which when not included fixes both behaviours and make them more consistent to what users would expect. This has been requested several times: https://groups.google.com/d/msg/vim_use/aaBqT6ECkA4/ALf4odKzEDgJ https://groups.google.com/d/msg/vim_dev/Dpn3xtUF16I/T6JcOPKN6usJ http://www.reddit.com/r/vim/comments/26nut8/why_does_cw_work_like_ce/ https://groups.google.com/d/msg/vim_use/vunNWLFWfQg/MmJh_ZGaAgAJ vim#4390 So in summary, if you want to have the w motion work more consistent, remove the 'z' from the cpo settings. related: vim#4390 Signed-off-by: Christian Brabandt <cb@256bit.org>
Problem: vi: d{motion} and cw command work differently than expected Solution: add new cpo-z flag to make the behaviour configurable There are two special vi compatible behaviours (or should I say bugs?): 1): cw behaves differently than dw. That is, because cw is special cased by Vim and is effectively aliased to ce. POSIX behaviour is documented here: https://pubs.opengroup.org/onlinepubs/9699919799/utilities/vi.html#tag_20_152_13_81 2): d{motion} may make the whole delete operation linewise, if the start and end of the motion are on different lines and there are only blanks before the start and after the end of the motion. Did not find a related POSIX link that requires this behaviour. Both behaviours can be considered inconsistent, but we cannot easily change it, because it would be a backward incompatible change and also incompatible to how classic vi behaved. So let's add the new cpo flag "z", which when not included fixes both behaviours and make them more consistent to what users would expect. This has been requested several times: https://groups.google.com/d/msg/vim_use/aaBqT6ECkA4/ALf4odKzEDgJ https://groups.google.com/d/msg/vim_dev/Dpn3xtUF16I/T6JcOPKN6usJ http://www.reddit.com/r/vim/comments/26nut8/why_does_cw_work_like_ce/ https://groups.google.com/d/msg/vim_use/vunNWLFWfQg/MmJh_ZGaAgAJ #4390 So in summary, if you want to have the w motion work more consistent, remove the 'z' from the cpo settings. related: #4390 closes: #15263 Signed-off-by: Christian Brabandt <cb@256bit.org>
w in cw is same as ce
When
w
combine withc
,cw
behaves same asce
.They both delete from current cursor to end of current word and insert.
But
cw
should delete from current cursor to where until next word which contain the blanks between it and next word.To Reproduce
Expected behavior
cw
has two parts, delete and insert. its deletion should be likedw
which delete until next word, including blanks.Environment
The text was updated successfully, but these errors were encountered: