Skip to content

Basic Renaming

Rename a function across your entire codebase:

Terminal window
# Generate a plan and review
renamify plan getUserName fetchUserProfile
# Apply the changes
renamify apply

Or use the fast-path:

Terminal window
# Plan, preview, confirm, and apply in one command
renamify rename getUserName fetchUserProfile

JavaScript/TypeScript files:

// Before
function getUserName(id) { ... }
const name = getUserName(userId);
export { getUserName };
// After
function fetchUserProfile(id) { ... }
const name = fetchUserProfile(userId);
export { fetchUserProfile };

Python files:

# Before
def get_user_name(user_id): ...
name = get_user_name(id)
# After
def fetch_user_profile(user_id): ...
name = fetch_user_profile(id)

Files and directories:

  • utils/getUserName.jsutils/fetchUserProfile.js
  • tests/get_user_name.test.pytests/fetch_user_profile.test.py

Rename variables and constants:

Terminal window
renamify rename apiKey secretKey

Various naming conventions:

// Before
const apiKey = "...";
const API_KEY = process.env.API_KEY;
const api_key = config.api_key;
// After
const secretKey = "...";
const SECRET_KEY = process.env.SECRET_KEY;
const secret_key = config.secret_key;

Rename React/Vue components:

Terminal window
renamify rename UserCard ProfileCard

Component files:

  • components/UserCard.tsxcomponents/ProfileCard.tsx
  • components/user-card.vuecomponents/profile-card.vue

Component usage:

// Before
import UserCard from './UserCard';
<UserCard user={currentUser} />
// After
import ProfileCard from './ProfileCard';
<ProfileCard user={currentUser} />

Rename classes across multiple files:

Terminal window
renamify rename DatabaseManager DataManager
# Before
class DatabaseManager:
def __init__(self): ...
db_manager = DatabaseManager()
# After
class DataManager:
def __init__(self): ...
data_manager = DataManager()

If you make a mistake, easily undo:

Terminal window
# See recent operations
renamify history
# Undo the last operation
renamify undo abc123-20241201-143022
# Or redo if you change your mind
renamify redo abc123-20241201-143022