Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to yank words between dots on multiple lines in VIM?

I try to find the best way to copy (all occurrences) and paste (all the occurrences somewhere else) the second word in between the dots in this example case with vim (without plugins):

1 somename.xyz.something
2 so.someday.zzzz
3 text.example.fese.efsse

The result after I paste it somewhere else:

5 xyz
6 someday
7 example

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

I would copy the lines in question (e.g. yip or through visual mode) and paste them to the desired location, so you’d get:

somename.xyz.something
so.someday.zzzz
text.example.fese.efsse

somename.xyz.something
so.someday.zzzz
text.example.fese.efsse

And then delete the unwanted parts. For example by selecting them in visual mode and running :'<,'>normal 0df.f.D, resulting in:

somename.xyz.something
so.someday.zzzz
text.example.fese.efsse

xyz
someday
example
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading