I have created a small vim-remotions plugin that allows to repeat the last motion using the ; and , keys (like for the f and t motions).
By default it repeats the following motions: ]m, ]M, ]], ][, }, g;, ]b, ]l, ]q, ]t, ]g.
It use the motion as they are defined in the buffer by the filetype.
The list of motions it repeats is configurable.
It can repeat the motion and their count or only the motion.
It can repeat the motion in the direction of the initial motion (like ; and , are doing for f and t) or in the direction of the document if considered more intuitive.
Here is the idea selected to do the job:
The plugin:
- map original motion to a
<Plug> version to not lose them
- map the selected motion to a function that:
- store the necessary information about the motion
- the backward and forward associated sequence
- the count if any
- use the
<Plug> version to execute the motion
- map
; and , to a function that used the stored information to repeat the motion.
The mappings are done in at the buffer level since the motion can be filetype specific.
The mappings are redone when the filetype is set or changed.
Thanks to @romainl for his hints.