Is there a way (or package) to search and replace code like:
class Account
def list_accounts
end
end
to
class Company
def list_companies
end
end
Basically I want to replace account(s) with compan(y/ies)
Vim does this with Subvert
Is there a way (or package) to search and replace code like:
class Account
def list_accounts
end
end
to
class Company
def list_companies
end
end
Basically I want to replace account(s) with compan(y/ies)
Vim does this with Subvert
By default, emacs retains the cases when replacing.
From the emacs manual,
When the newstring argument is all or partly lower case, replacement commands try to preserve the case pattern of each occurrence. Thus, the command
M-x replace-string <RET> foo <RET> bar <RET>
replaces a lower case
foo
with a lower casebar
, an all-capsFOO
withBAR
, and a capitalizedFoo
withBar
. (These three alternatives—lower case, all caps, and capitalized, are the only ones that replace-string can distinguish.)
Ensure that the case-replace
variable is t
(which it is, by default).
You can try query-replace-regexp
(C-M-%
) then replace
account\(s\)?
with
compan\,(if (string= \1 "s") "ies" "y)
replace-string-with-plural
or equivalent.
query-replace
. That is, if you ask to replace "account" with "company", then "Account" will be replaced with "Company". Is that not what happens for you?