Yankees words are divided only by periods

I have such a line in the file

<echo>The app vendor is... app.server.name</echo> 

Using the cursor over the "r" in the "server", how can I pull out the "app.server.name" without going into visual mode, or without knowing how many words to pull out.

yiw will only clean up the word between periods.

+7
source share
2 answers
 Byt< 

B (to lead you to the beginning of a broken word)

yt< (to pull forward, up, but excluding "<").

+20
source

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>

+11
source

All Articles