Skip to content

Instantly share code, notes, and snippets.

View brfitzpatrick's full-sized avatar
🐜

Ben R. Fitzpatrick brfitzpatrick

🐜
View GitHub Profile
@brfitzpatrick
brfitzpatrick / swap values in emacs
Created July 24, 2017 01:38
swap values in emacs
M-x replace-regexp <RET>
\(dog\)\|cat <RET>
\,(if \1 "cat" "dog") <RET>
Beginning Line 3 with `\,` tells Emacs that this line should be evaluated as a Lisp expression.
The `\1` on Line three referres to the first grouped of characters defined with `(` and `)` on line 2.
Read line 3 as if `\1` replace with "cat" else replace with "dog"
You have to escape (i.e. preceed with `\`) the `(`, `)` and `|` characters for them to be treated as special characters