Ad blocker interference detected!
Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers
Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.
created 2006 · complexity basic · author Gerald Lai · version 5.7
One of Vim's best features is being able to record keystrokes and play them back repeatedly. To record keystrokes, the "q" key is used.
In the spirit of VimTip398, here's another suggestion for quick and easy playback. Place in vimrc:
:noremap Q @q
This allows playback of the recording that was put into the q register.
Example of recording and playback usage:
- Begin recording keystrokes by typing "qq".
- Perform your customized keystrokes.
- To end recording, type
q in normal/visual mode Ctrl-o q in insert mode
- To playback recording, hit the Caps Lock key and use "Q" in normal/visual mode. The Caps Lock key acts as a flip switch between recording and playback.
Playback can accept a count. For example, "5Q" repeats the recorded keystrokes 5 times.
If you'd still like to access Ex-mode like it was with the default "Q", use "gQ" instead. It has more features than the original Ex-mode.
I do the same thing except I map
@c to the function keys F2, F3 and F4. This way it's even less keystrokes plus you can have three macros at your fingertips instead of just the one.
To map the F2 function key, put this in your vimrc file:
nmap <F2> @a
Or map F2 to
@@. That way you only have to invoke a macro once explicitly like
@a, then repeat it by pressing F2.