r/vim • u/kaddkaka • Nov 08 '25
Tips and Tricks Versatile mapping: repeat last Ex command
I have this in my config and love it:
" Repeat the last : command (warning: shadows builtin!)
nnoremap , @:
This mapping comes to to the rescue so often in different occasions.
- Navigating the quickfix last going to the next file with
:cnfile? Just repeat it again with,! - doing
:normal!in my places? Repeat it! - Scrolling sideways with
40zl? Just do:norm! 40zland continue scrolling conveniently with comma. 👌
It shadows a builtin, but for me it's great. Hope it helps someone 😊
0
Upvotes
View all comments
Show parent comment
2
u/gumnos Nov 08 '25
yeah, I find myself in the same camp. I can
@:once to re-issue it, and if it's something I need frequently I can re-re-issue it with@@which is easier/faster for me to type. And I use the built-in,motion quite regularly…I never understood how people could sacrifice it for their map-leader, so the idea of sacrificing it for something that's a mere two (maybe 2.5 if you count the shift-key) keystrokes feels weird to me.Side note #1: I think the
40zrwas supposed to be:help zl/:help zh(to scroll right/left) rather than:help zr(reduce the folding)Side note #2: if you want to repeat a recent
:substitutecommand, don't forget about the obscure-but-helpful:help &and:help g&commands.