sponsor Vim development Vim logo Vim Book Ad

repeatable-motions.vim : Make most motions repeatable

 script karma  Rating 33/14, Downloaded by 2286  Comments, bugs, improvements  Vim wiki

created by
Mohammed Chelouti
 
script type
utility
 
description
While the motions f/F and t/T can be repeated with , and ; the default key mapping is not
only unintuitive it also requires the user to remember in what direction s/he moved with the previous f/t motion.

This nuisance brought me to rethink the idea of repeatable motions and resulted
in this plugin.

repeatable-motions.vim makes most default motions repeatable in an easy and
intuitive way. Perform a motion once (such as f) and repeat it simply with
<C-h> to the left and <C-l> to the right. The direction is always what you'd expect, no more remembering if you used f or F.

Additionally repeatable-motions.vim distinguishes between vertical and horizontal
motions. So [M can be repeated with <C-j> and <C-k> while still remembering your
previous horizontal movement.

Motions that are being repeated behave like normal motions, support counts and can be used in
operation-pending as well as visual-mode.

Everything works out of the box and making your own motion
repeatable is as easy as calling AddRepeatableMotion("<Up>", "<Down>", 1).
Buffer-, expression- and custom mappings are all handled without further ado.
 
install details
Extract into ~/.vim
Run :helptags ~/.vim/doc in vim

Or use a plugin manager (Vundle, Pathogen, vim-addon-manager)

If you want to change the default key mappings to repeat motions see :help repeatable-motions-mapping.
 

rate this script Life Changing Helpful Unfulfilling 
script versions (upload new version)

Click on the package to download.

package script version date Vim version user release notes
repeatable-motions.zip 1.2 2017-07-14 7.0 Mohammed Chelouti Bugfixes:
- Rectify inaccurate information in help and clear up some ambiguities.
- Fix [' and ]' (and any custom motion containing a single quote) throwing
  an error.

Features:
- Added <Plug>ReverseMostRecentMotion to perform most recent motion in
  the oppposite direction.
repeatable-motions.zip 1.1.1 2014-07-26 7.0 Mohammed Chelouti Features:
- Added 'g:repeatable_motions_default_mappings' to disable all default
  mappings.
Bugfixes:
- Renamed GetPreviouslyPreformedMotion() to |GetPreviouslyPerformedMotion()|.
repeatable-motions.zip 1.1 2014-05-09 7.0 Mohammed Chelouti Bugfixes:
- RemoveRepeatableMotion() can now remove motions containing <Leader>.
- Mappings with special keys (e.g. <Down> or <C-w>) are handled correctly.
- Workaround for t/T now doesn't get stuck on first occurrence unless
  'cpoptions' contains ';'.

Features:
- Added functionality to repeat most recent motion in the same direction.
repeatable-motions.zip 1.0 2014-04-07 7.0 Mohammed Chelouti Initial upload
ip used for rating: 142.132.191.50

If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to the maillist. Help Bram help Uganda.
   
Vim at Github