Emacs kaizen: ace-jump-zap lets you use C-u to zap to any character

This entry is part of 4 in the series Emacs Kaizen

I’m perpetually using M-z to zap-to-char and then typing the character back in, because I really should be using zap-up-to-char instead. But if I’m going to get the hang of fiddling with my muscle memory so that I do things the Right Way, I might as well use this opportunity to practise using ace-jump-zap instead. The ace-jump-zap-up-to-char-dwim and ace-jump-zap-to-char-dwim functions behave like their normal equivalents, but if you C-u them, you get ace-jump type behaviour allowing you to quickly zap to any character you see. And since I mentally think of M-z as not including the character, I may as well map it so that M-z behaves that way.

Now I just have to remember that C-u does cool stuff…

(use-package ace-jump-zap
  :ensure ace-jump-zap
  (("M-z" . ace-jump-zap-up-to-char-dwim)
   ("C-M-z" . ace-jump-zap-to-char-dwim)))
Series NavigationEmacs: M-y as helm-show-kill-ring »
  • jcs

    Actually, stock Emacs has both versions but the zap up to case doesn’t have an autoload. I wrote about it here. You won’t be surprised to discover that I learned this from Steve Purcell.

    • jcs: I knew about zap-up-to-char, but I didn’t know it wasn’t autoloaded. I guess I always just happen to have misc.el already loaded? =) Anyway, the ace- part of it is pretty cool. I just used it today to get rid of part of an Org link by zapping up to the appropriate ].

      Thanks for sharing your write-up!