1. Fast and dirty: include dots in the phrase
:se iskeyword+=46
Now y i w will do what you want :)
2. Correct solution: define a text object
As Benoit mentions, the above may be side effects that you do not want 1
In an earlier answer ( vim: select inside points ) I describe how to warp a text object to select inside points (shown below). You can use this as a basis for defining a similar text object that selects words, including periods:
This does not require any changes to the iskeyword configuration :)
<sub>
xnoremap <silent>. f.oT.o xnoremap <silent>afoF.o xnoremap <silent>itoT.o onoremap <silent>. :<Cu>exec 'normal v' . v:count1 . '.'<CR> onoremap <silent>a. :<Cu>exec 'normal v' . v:count1 . 'a.'<CR> onoremap <silent>i. :<Cu>exec 'normal v' . v:count1 . 'i.'<CR>
Examples for the contents of the following buffer (cursor w ):
someobject.some-property-with-hyphens.SUB.otherproperty
- v . selects
some-property-with-hyphens. in visual mode - v a . selects
.some-property-with-hyphens. in visual mode - v i . selects
some-property-with-hyphens in visual mode
Movements can be chained and take count :
- v . . selects
some-property-with-hyphens.SUB. in visual mode - v 2. also selects
some-property-with-hyphens.SUB. in visual mode - v 2 a . selects
.some-property-with-hyphens.SUB. in visual mode - v 2 i . selects
some-property-with-hyphens.SUB in visual mode
You can use operators as operators for any editing command:
- d . leads to
someobject.SUB.otherproperty - c i . shortname result of
someobject.shortname.SUB.otherproperty - c 2 . get (" leads to
someobject.get("otherproperty
It doesnโt matter where the cursor begins in the "dot separator". Note that for convenience, all displays in the visual mode position the cursor at the end of the selection (so that you can continue to expand the selection, for example, % and other movements).
1 see here a little information: vim: select inside Sub>
sehe
source share