Skip to content

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_case
acronymSet # camelCase
AcronymSet # PascalCase
ACRONYM_SET # SCREAMING_SNAKE_CASE
acronym-set # kebab-case
Acronym-Set # Train-Case
--exclude-acronyms # CLI flag segment
excludeAcronyms # mixed-case config key

Naive replace produces broken or mixed results:

inflection_rule_set # ok
inflection_ruleSet # wrong in camel
Inflection_ruleSet # broken Pascal
INFLECTION_RULE_SET # ok
inflection_rule-set # mixed separators
Inflection_rule-Set # broken Train
--exclude-inflection_rules # wrong plural placement
excludeInflection_rules # broken camel suffix

Renamify produces consistent, style-aware results:

inflection_rule_set
inflectionRuleSet
InflectionRuleSet
INFLECTION_RULE_SET
inflection-rule-set
Inflection-Rule-Set
--exclude-inflection-rules
excludeInflectionRules

How: we detect the container style, generate the correct target variant for that style, and only replace full tokens, not substrings.

Example: rename File to Document.

Input:

FileManager
TempFileHandler
file_manager_service
ProfileImage # should not change
FileSystemWatcher

Naive regex can overmatch:

ProfileImage -> ProDocumentImage # wrong

Renamify honors token boundaries:

FileManager -> DocumentManager
TempFileHandler -> TempDocumentHandler
file_manager_service -> document_manager_service
ProfileImage -> ProfileImage
FileSystemWatcher -> DocumentSystemWatcher

Acronyms are common: HTTPSConnection, XMLHttpRequest, parseURL, ID, URLParser.

Renamify’s tokenizer understands acronym spans for matching:

  • HTMLGenerator is parsed as HTML + Generator, so searches for html_generator or HTMLGenerator both match correctly.
  • URLParser matches as URL + Parser, not UR + LParser.
  • Rename-Tool-CLI is Train-Case with an acronym tail. Searching for rename_tool correctly matches the Rename-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.md
smart_search_and_replace.exe -> renamify.exe
SmartSearchAndReplace.java -> Renamify.java

And updates common import patterns:

import smart_search_and_replace.core -> import renamify.core
require('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.

Real-world examples:

SmartSearchAndReplace-specific
smart-search-and-replace-Guide
Run-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”.

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.

Renames must be reversible without drift:

project1 -> workspace1 -> project1
b2b_sales -> b2c_sales -> b2b_sales
ARM64_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.

  • 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 vs WebAddresses
  • Words that only contain URL but are different, like CURL
  • Literals and comments, like https://example.com/url or @param {URL}
  • Constants like URL_PATTERN
  • Filenames like url_utils.js that should become web_address_utils.js

Renamify handles matching and boundaries so you can review a single plan and apply confidently.