I has in vim:
foo barba[r]bar
foo
[] indicates cursor position
and when I use vaw or viw the barbarbar is higlithted. And it is ok.
But I would like understand – why? v is for visual mode, a – i dont know why, and w normaly approach to the begin of new word.
I also checked caw and ciw. First one deletes barbarbar and leave cursor after foo without space, second will leave space after foo, both enters insert mode…
So why it works? Is any referance for this in vim help? Could anyone translate it for vim language?
See
:help text-object. This explains it all better than any guy here could.Here is the whole section:
Note that you can create your own text objects with two commands (for example you would like “K” to be a new text object : when in operator mode you want to select three characters with cursor at the centre, and in visual mode you would like to extend the selection by 1 character to both ends (provided that your cursor is at the end of the selection):