Thursday, February 11, 2016

Re: Feature or bug? Funny behaviour of cw on whitespace.

On 11.02.16 05:06, Elmar Hinz wrote:
> > The w motion is then perfectly as specified, and as expected.
> > It is particularly handy when correcting indentation of a few
> > lines to align with a leading line of arbitrary indentation:
> >
> > 1) Move to start of leading line, with ^.
> > 2) j
> > 3) dw
> > 4) Loop to 2 until done, using '.' at 3, i.e. j.j.j.j.
> >
> >
> > Erik
>
> Hi Erik,
>
> sure the dw motion. My questions here cover the cw motion on
> whitespace in special. Strange stuff.

Noo-oo, it is cw within a word which is strange. Invoked from whitespace
it is unsurprising, going to the start of the nth word, exclusive.
Perfectly consistent with w by itself.

Please read ":help cw", which makes clear that it is deliberately
strange within a word. A mapping to provide consistent behaviour is
proffered there.

Vim has "compatible" and "nocompatible" modes w.r.t. vi. Perhaps you
might think of doing the same w.r.t. vim. Whether vi compatibility is
retained in your vim-n-a-bit, is another question. (Look at the vi bug
described at ":help cw".)

> Sure, that is something you likely never hit upon, unless you try to
> clone that behaviour and ask yourself should I really do that or
> should it be improved in Vim itself.

In this instance, it is already improved in Vim itself. ;-)
(Each user can choose convenience or correctness, according to
preference - that's close to perfection.)

Erik

--
--
You received this message from the "vim_use" 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

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment