Why Not Search and Replace?
Renaming words in a real codebase is often more complex than a simple search-and-replace. Case styles, separators, acronyms, filenames, and imports all need to change in sync. This page shows concrete failure modes of naive search or regex, and how Renamify handles them safely.
TLDR: Renamify tokenizes identifiers, understands case styles and separators, knows common acronyms, respects boundaries, renames files and directories consistently, previews the plan, and applies changes atomically with undo.
1. Case style preservation across variants
Section titled “1. Case style preservation across variants”Example: rename acronym
to inflection_rule
.
Your codebase contains:
acronym_set # snake_caseacronymSet # camelCaseAcronymSet # PascalCaseACRONYM_SET # SCREAMING_SNAKE_CASEacronym-set # kebab-caseAcronym-Set # Train-Case--exclude-acronyms # CLI flag segmentexcludeAcronyms # mixed-case config key
Naive replace produces broken or mixed results:
inflection_rule_set # okinflection_ruleSet # wrong in camelInflection_ruleSet # broken PascalINFLECTION_RULE_SET # okinflection_rule-set # mixed separatorsInflection_rule-Set # broken Train--exclude-inflection_rules # wrong plural placementexcludeInflection_rules # broken camel suffix
Renamify produces consistent, style-aware results:
inflection_rule_setinflectionRuleSetInflectionRuleSetINFLECTION_RULE_SETinflection-rule-setInflection-Rule-Set--exclude-inflection-rulesexcludeInflectionRules
How: we detect the container style, generate the correct target variant for that style, and only replace full tokens, not substrings.
2. Compound word boundaries
Section titled “2. Compound word boundaries”Example: rename File
to Document
.
Input:
FileManagerTempFileHandlerfile_manager_serviceProfileImage # should not changeFileSystemWatcher
Naive regex can overmatch:
ProfileImage -> ProDocumentImage # wrong
Renamify honors token boundaries:
FileManager -> DocumentManagerTempFileHandler -> TempDocumentHandlerfile_manager_service -> document_manager_serviceProfileImage -> ProfileImageFileSystemWatcher -> DocumentSystemWatcher
3. Acronym intelligence for matching
Section titled “3. Acronym intelligence for matching”Acronyms are common: HTTPSConnection
, XMLHttpRequest
, parseURL
, ID
, URLParser
.
Renamify’s tokenizer understands acronym spans for matching:
HTMLGenerator
is parsed asHTML
+Generator
, so searches forhtml_generator
orHTMLGenerator
both match correctly.URLParser
matches asURL
+Parser
, notUR
+LParser
.Rename-Tool-CLI
is Train-Case with an acronym tail. Searching forrename_tool
correctly matches theRename-Tool
subspan and preserves-CLI
.
Acronym matching is configurable:
--no-acronyms
disables acronym-aware matching.--include-acronyms "API,CLI,ID"
--exclude-acronyms "ID"
--only-acronyms "API,CLI"
Note: snake_case is always lower for matching and rendering. Screaming snake is the uppercase variant. Acronym options affect matching detection and case inference, not whether snake uses uppercase.
4. File and directory renaming with consistency
Section titled “4. File and directory renaming with consistency”Renamify updates file and directory names alongside contents, in the right order, and checks for collisions.
Example: rename smart_search_and_replace
to renamify
.
It handles:
/smart_search_and_replace/ -> /renamify//docs/smart-search-and-replace-guide.md -> /docs/renamify-guide.mdsmart_search_and_replace.exe -> renamify.exeSmartSearchAndReplace.java -> Renamify.java
And updates common import patterns:
import smart_search_and_replace.core -> import renamify.corerequire('smart-search-and-replace') -> require('renamify')use smart_search_and_replace::scanner; -> use renamify::scanner;
Root directory rename is suggested with a ready-to-paste snippet and opt-in flag to perform automatically.
5. Hyphenated mixed-style patterns
Section titled “5. Hyphenated mixed-style patterns”Real-world examples:
SmartSearchAndReplace-specificsmart-search-and-replace-GuideRun-SmartSearchAndReplace
Renamify treats the hyphen as a separator between differently styled segments, replaces only the matching subspan, and preserves each segment’s style. For example:
Rename-Tool-CLI -> Code-Transform-Engine-CLI
This works because the tokenizer classifies the segment as Train-Case with an acronym tail, not as generic “mixed”.
6. Special tokens that must be preserved
Section titled “6. Special tokens that must be preserved”Renamify never splits these incorrectly:
arm64
,amd64
2FA
K8S
project1
,b2b
,b2c
These are single tokens with digits and are preserved in style-aware replacements.
7. Round-trip preservation
Section titled “7. Round-trip preservation”Renames must be reversible without drift:
project1 -> workspace1 -> project1b2b_sales -> b2c_sales -> b2b_salesARM64_ARCH -> X86_ARCH -> ARM64_ARCH
Renamify tracks exact tokenization and case rules so round-trips restore the original. We run end-to-end roundtrip tests on CI to ensure we catch any unhandled edgecases.
8. Safety and previews
Section titled “8. Safety and previews”- Ignores binaries and build artifacts by default. (Same rules as ripgrep, same -u, -uu, -uuu flags.)
- Honors
.gitignore
,.ignore
,.rgignore
, and.rnignore
. - Plan and preview before apply.
- Apply is atomic with rollback and undo history.
Real-world complexity: renaming URL
to WebAddress
Section titled “Real-world complexity: renaming URL to WebAddress”Challenges include:
URLParser
,parseURL
,HTTPS_URL
,url_encoder
- Plurals like
URLs
vsWebAddresses
- Words that only contain
URL
but are different, likeCURL
- Literals and comments, like
https://example.com/url
or@param {URL}
- Constants like
URL_PATTERN
- Filenames like
url_utils.js
that should becomeweb_address_utils.js
Renamify handles matching and boundaries so you can review a single plan and apply confidently.