Given the following code sample:
uint8_t i, in, ni;
i = in = 2; ni = 1;
while (2 == i > ni) in++;
How can I replace i, in, and ni<
Shorter Emacs solution:
C-M-% (query-replace-regexp)
To match: \<\(i\|in\|ni\)\> (I assume you want to match whole words only)
Replace with: \,(case (intern \1) (i "in") (in "ni") (ni "i"))
You'll need to require 'cl
at some point before doing this to get the case
macro from the CL package. You could achieve the same effect without that package, but it wouldn't be as terse.
EDITING TO ADD: Actually, it could be as terse, as I realized when answering a similar question on Reddit recently.
To match: \<\(?:\(i\)\|\(in\)\|ni\)\>
Replace with: \,(if \1 "in" (if \2 "ni" "i"))