Thursday, January 7, 2010

exclusive vs. inclusive actions and selection

I'm a little puzzled over "exclusive" vs. "inclusive" actions and how
they interact with the 'selection' option.

Specifically, the 'e' and 'g_' commands seem inconsistent to me.

:help e says the cursor will be placed on the end of a word
(inclusive).

:help g_ says the cursor will be placed on the last nonblank character
in a line (also inclusive).

So, suppose I have a line with one word, like this:

anitdisestablishmentarianism

With 'selection' set to "inclusive", ^ve and ^vg_ do the same thing,
with a visual selection that looks like:

|anitdisestablishmentarianism|

With 'selection' set to "exclusive", ^ve gives:

|anitdisestablishmentarianism|

But ^vg_ gives:

|anitdisestablishmentarianis|m

This happens even with trailing whitespace on the line.

Why do two motions, both inclusive, that put the cursor in the same
place, create a different visual selection?

No comments: