Skip to content

Comment on Learn Emacs: Keyboard Macrosparent

Comments

There is the \# character, which is replaced with the number of times a replacement has been done. So,

   M-x replace-regexp
      Replace regexp: test\(.+\)
      Replace regexp with test\#
You can actually drop arbitrary lisp in the middle of search/replace expressions. So, if you'd like to number from 1 instead of 0,
   M-x replace-regexp
      Replace regexp: test\(.+\)
      Replace regexp with test\,(1+ \#\)
I'm sure with more lisp tricks, you can get delimited lists:
   M-x replace-regexp
      Replace regexp: test\(.+\)
      Replace regexp with test\,(aref ["one", "two", "three"] (mod \# 3))
(Not sure that works, but you get the idea).

Anyway, all of this was basically stolen from Steve Yegge. You should totally go read his article if you're interested: http://steve-yegge.blogspot.com/2006/06/shiny-and-new-emacs-...

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.