Thomas
Thomas

Reputation: 2163

How to replace multiple characters at once in emacs

What is the quickest way to replace multiple characters at once in emacs? For instance I would like to act on the region and replace 1 with a, 2 with b, ..., 9 with i.

Upvotes: 3

Views: 989

Answers (1)

Inaimathi
Inaimathi

Reputation: 14065

You can stitch elisp into regex replacements (not sure if you can do the same with replace-string). For instance,

M-x query-replace-regexp \([1-9]\) \,(char-to-string (+ 96 \#1))

should replace single digits 1-9 with the letters a-i as appropriate.

Upvotes: 5

Related Questions