1

Re: yb

Hi
Silly question.
when I am yanking back a word (yb), the letter under the cursor is not yanked.
when I am yanking forward a word (yw), the letter under the cursor IS yanked.

so how can I yank back a word so the letter under the cursor will be yanked?  (-:

Thanks.

Last edited by kroiz (2006-11-22 08:46:23)

2

Re: yb

Hi kroiz,

Not a silly question at all. 'b' is a character-wise exclusive motion, that's why the rightmost character is not included (I think this is for simmetry with 'w', which is also exclusive). Motions such as 'e' or 'ge' (backwards end of word, vim-specific) are inclusive, but you can't easily select a word with them.

One little known fact is that you can change the linewise/blockwise/charwise and inclusive/exclusive nature of a motion when used as an operator argument. You use the v/V/Ctrl-V commands used to enter visual mode. If you use uppercase 'V', the motion is turned into linewise. If you use 'v', and the motion is already charwise, its exclusive/inclusive nature is toggled. Thus, yvb will do what you want, that is, yank from the current point to the beginning of the 'word' including the character currently under the cursor.

One other option is to use the text object motions: 'iw', 'aw', etc... 'yiw' will yank the current work (without any surrounding spaces), while 'yaw' will yank the current word including trailing spaces (or leading whitespace, if there are no trailing spaces).

Best regards,

  Jon

3

Re: yb

very interesting thanks.
I think I will use the yiw, that way I could use the same command regardless of where the cursor is. (beginning or end)
thanks alot