On Fri, Jan 19, 2024 at 5:50 PM Gary Johnson <garyj...@spocom.com> wrote:
>
> On 2024-01-16, Britton Kerin wrote:
> > The sequence 'vaw' (visual around word is how I think of it) does
> > weird things depending on white space:
> >
> >   * 'vaw' while on 'a' in 'foo bar' selects ' bar' (space followed by bar)
> >
> >   * 'vaw' while on 'a' in 'foo bar ' (with trailing space) selects
> > 'bar ' (bar followed by space)
> >
> > Why?
> >
> > I could understand (though not exact agree with the policy) if spaces
> > are being viewed as part of particular words in this context, but I
> > don't see why adding a space after bar causes the one before it to not
> > be selected.
>
> I can't find where this is documented, but Vim defines "a word", for
> most purposes, as a sequence of word characters followed by white
> space.  That definition can't hold at the end of the line, so the
> developers were left with a choice of including the preceding white
> space or not including any white space.  The choice to include the
> preceding white space is pragmatic.
>
> If you want to cut a word from one place and paste it somewhere
> else, it is convenient for that cut to include white space so that
> you don't have to remove it separately from the cut location nor add
> it separately to the paste location.  There is no following white
> space at the end of a line, so the preceding white space is included
> instead.  Also, if you delete a word at the end of a line,
> presumably you don't want to leave white space at the end of that
> line.
>
> That logic is also applied in other situations where a sequence of
> word characters is followed by a non-word character such as
> a closing parenthesis.
>
> Regards,
> Gary

It is documented under ":help aw" (aw, i.e. "a word" being the
"motion" applied after v sets characterwise visual). «Leading or
trailing white space is included, but not counted.» IOW, white space
is included on one side (but not both). If Vim doesn't find white
space where it looks for it first (after the word IIUC) then it looks
on the other side.

Best regards,
Tony.

-- 
-- 
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

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/CAJkCKXt2YR1Rz4QETmr404FMyf1ofdypHHuorm22HVjshFcudw%40mail.gmail.com.

Raspunde prin e-mail lui