prompt-toolkit / python-prompt-toolkit

Library for building powerful interactive command line applications in Python
https://python-prompt-toolkit.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
9.34k stars 716 forks source link

Vi-mode `cw` inconsistent with actual vi #394

Open OJFord opened 8 years ago

OJFord commented 8 years ago

In Vi,

"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. -- http://vimdoc.sourceforge.net/htmldoc/motion.html#word-motions

This means that, if I type "brew search xonsh" in Vi(m), with my cursor placed at the beginning of 'search'; cw will allow me to type install<esc> to change the sentence to "brew install xonsh".

In prompt_toolkit however, the same process would result in "brew installxonsh".

It may sound trivial, but since vim-users will spend more time using vim commands in vim than anywhere else, it's hard to remember the different behaviour and may cause problems.

jonathanslenders commented 8 years ago

Hi @OJFord , Thanks a lot for pointing this out! I try to be consistent with Vi(m), so if we do something different, then that's a bug. I'll try to find a fix for this. (If you have a fix, that's also welcome. ;) ) Thanks again, Jonathan

OJFord commented 8 years ago

Thanks :)

I don't really have enough of a model of how this works, but it seems like maybe the w/W handlers here could instead return e/E if the operation is c?

OJFord commented 3 years ago

I use fish rather than xonsh these days; which is written in C++ and so doesn't use this library (or have this problem) - consequently I don't know if this is still an issue or not, but since only one other 👍🏻's shown any interest I'll close it.

(Feel free to re-open, @ maintainers, if it is something you want, or @ anyone else ping me and I'll gladly re-open if it's still a problem and others care about it. 🙂)

hardkrash commented 3 years ago

I have hit this issue are well, please reopen.