Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vim: Repeat previous motion?

Tags:

vim

Let's say that I'm in visual mode, and I type "aw" to extend the visual area to include the next word. I'd like to then include the next couple of words. Is there a single key that I can press to repeat the previous motion (include text object motions)?

I'm aware that '.' repeats the previous change, and 'n' repeats the previous search, amongst other 'repeat' commands, but I'm unaware of any command to repeat the previous motion (whatever it was).

like image 536
MikeTheTall Avatar asked Oct 24 '14 17:10

MikeTheTall


People also ask

How do you repeat the same action in Vim?

vim Normal mode commands (Editing) Repeat the Last Change Your cursor will be at position 1 of line 1, and all you need to do to fix the next two lines is press j. twice - that is, j to move down a line and . to repeat the last change, which was the addition of the I .

What does period do in Vim?

The dot command The dot command is a simple and powerful tool in Vim. It allows repeating the last change by pressing the . (period) key in Normal mode.


1 Answers

Well there is a command to repeat every motion made with f,t,F or T Remember that
fx takes to the next occurrence of the character x
Fx takes to the previous ocurrence of x
tx takes you to the character before the next occurrence of x
Tx takes you you to the character after the previous occurrence of x
to repeat those motions press

; 

to repeat them backwards (in the oposite direction) press

, 
like image 150
Santi Avatar answered Sep 19 '22 17:09

Santi