Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can VIM do this Sublime trick?

Tags:

vim

I want to edit this text:

Aenean vel sem bibendum, eleifend odio a, dictum nibh.
The third word in the above line is 
Morbi eget est vitae quam ultricies porta vitae quis nunc.
The third word in the above line is 
Praesent accumsan ex a laoreet cursus.
The third word in the above line is 
Quisque efficitur lectus at dolor mollis, sit amet tristique libero lobortis.
The third word in the above line is 

to this text:

Aenean vel sem bibendum, eleifend odio a, dictum nibh.
The third word in the above line is sem
Morbi eget est vitae quam ultricies porta vitae quis nunc.
The third word in the above line is est
Praesent accumsan ex a laoreet cursus.
The third word in the above line is ex
Quisque efficitur lectus at dolor mollis, sit amet tristique libero lobortis.
The third word in the above line is lectus

To do this with Sublime

Select repeated part
ALT+F3
UpArrow
HOME
3 x CTRL+RightArrow
CTRL+Shift+LeftArrow
CTRL+C
DownArrow
END
CTRL+V

this trick is very useful in many cases. can VIM do it?

like image 574
tuxohaib Avatar asked Jun 11 '26 19:06

tuxohaib


1 Answers

It should work easily with a macro. If you have your cursor on the first character of the first line then:

qq: start recording macro named q

2w: advance two words

yw: yank (copy) word

j$: jump to next line and go to end of line

p: paste what you've yanked

+: go to start of next line

q: stop recording macro.

3@q: execute macro named q 3 times

like image 186
Axnyff Avatar answered Jun 17 '26 16:06

Axnyff



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!