Created
July 24, 2017 01:38
-
-
Save brfitzpatrick/68ccaffdda5c204e4d775ec2d08877c1 to your computer and use it in GitHub Desktop.
swap values in emacs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment